Commit graph

18461 commits

Author SHA1 Message Date
François Best
e4158f6cec
fix: Don't reset shallow URL updates on prefetch (#58297)
## Description

Between 14.0.2-canary.6 and 14.0.2-canary.7, a change was introduced in vercel/next.js#56497 that turned the Redux store state into a Promise, rather than a synchronous state update.

This caused the `sync` function -- used to send state updates to the Redux Devtools -- to be recreated on every dispatch, which in turn, by referential instability, caused the `HistoryUpdater` component to re-render and trigger a `history.replaceState` with no particular change, but with the internal `canonicalUrl`.

When an app does a soft/shallow navigation by calling history methods directly (currently the only way to do shallow search params updates in the app router), these changes would have been overwritten by any prefetch (eg: hovering or mounting a Link), which is usually a no-op for the navigation state.

This PR changes the `sync` function to take the state as an argument rather than as a closure. The whole app router state is also unwrapped only once, and fed to the HistoryUpdater. Changes to its contents made by reducers will cause the HistoryUpdater effect to re-run, triggering history updates and a call to the sync function.

## Context

I maintain [`next-usequerystate`](https://github.com/47ng/next-usequerystate), which is used in the Vercel dashboard, and which is impacted by this change (see 
[#388](https://github.com/47ng/next-usequerystate/issues/388)).

## History

@timneutkens introduced the `sync` function and the whole Redux devtools reducer in vercel/next.js#39866, with the note:

> a new hook useReducerWithReduxDevtools has been added, we'll probably want to put this behind a compile-time flag when the new router is marked stable but until then it's useful to have it enabled by default (only 
when you have Redux Devtools installed ofcourse). 

If a different direction is needed to keep sending `RENDER_SYNC` actions to Redux devtools, I'll be happy to rework this PR to move the `sync` function into the action queue.

## Changes

- [x] Added e2e test. Requires a `start` mode as prefetch links are disabled in development. Test was verified to fail from next@>=12.0.2-canary.7 without the fix.


Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-11-14 19:29:18 +00:00
Zack Tanner
d6f1d94f2f
Revert "fix hmr event, and avoid RSC fetch on any message" (#58452)
Reverts vercel/next.js#58403

Seems to be resulting in consistent CI failures

[x-ref](https://github.com/vercel/next.js/actions/runs/6856034177/job/18658084460)
[x-ref](https://github.com/vercel/next.js/actions/runs/6864944315/job/18667863954)
2023-11-14 18:51:44 +00:00
Tobias Koppers
1ee50b8e57
add test case to failing list for turbopack (#58435) 2023-11-14 15:22:03 +01:00
vercel-release-bot
08e5424ddc v14.0.3-canary.7 2023-11-14 10:25:41 +00:00
Tobias Koppers
bcd0cb8948
fix branch name (#58132)
fix the branch name of the workflow
2023-11-14 11:23:02 +01:00
Tobias Koppers
21480779e0
fix hmr event, and avoid RSC fetch on any message (#58403)
### What?

notify `__NEXT_HMR_CB` only when the RSC HMR update rerendered

### Why?

the event was too early
2023-11-14 11:22:17 +01:00
vercel-release-bot
82821c7942 v14.0.3-canary.6 2023-11-13 23:22:10 +00:00
Aki Matsumoto
4fe968bb71
Fix: expected "catch all routes" are not matched in “parallel routes" (#58368)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?



-->
This PR fixes a bug where the expected catch-all route would not match
if there were multiple "catch-all routes" under the "parallel route”.

The page on the non-parallel routes path matches the catch all routes.
that exist on the more detailed path.
However, under parallel routes, it matches the most parent page of all
the pages with catch all routes.

For example, if there are files like below:
```
app/@sidebar/[...catchall]/page.tsx
app/@sidebar/dashboard/[...catchall]/page.tsx
```
When accessing `/foo`, it should match
`app/@sidebar/[...catchall]/page.tsx`, and this is working correctly.
However, when accessing `/dashboard/foo`, it should match
`app/@sidebar/dashboard/[...catchall]/page.tsx`, but
`app/@sidebar/[...catchall]/page.tsx` is being matched instead.

## Repository to reproduce
https://github.com/nonoakij/fix-parallel-routes-with-catch-all

## Related PR
https://github.com/vercel/next.js/pull/58215

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
2023-11-13 23:26:45 +01:00
JJ Kasper
dc59d3cca9
Update CLI version for deploy examples job (#58318)
Fixes:
https://github.com/vercel/next.js/actions/runs/6830557044/job/18578715963
2023-11-13 11:36:51 -08:00
Asad Khan
1eee93cc94
Update 08-parallel-routes.mdx (#58393)
Fixed Typo

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-11-13 17:55:28 +01:00
Tim Neutkens
797fecb0c6
Add experimental support for history.pushState and history.replaceState (#58335)
## What?

This PR introduces support for manually calling `history.pushState` and `history.replaceState`.

It's currently under an experimental flag:

```js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    windowHistorySupport: true,
  },
}

module.exports = nextConfig
```

Going forward I'll refer to `history.pushState` as `replaceState` is interchangable.
 
When the flag is enabled you're able to call the web platform `history.pushState` in the usual way:

```js
const data = {
	foo: 'bar'
}
const url = '/my-new-url?search=tim'
window.history.pushState(data, '', url)
```

Let's start by explaining what would happen without the flag:

When a new history entry is pushed outside of the Next.js router any back navigation to that history entry will cause a browser reload as it can no longer be used by Next.js as the required metadata for the router is missing. In practice this makes it so that pushState/replaceState is not feasible to be used. Any pathname / searchParams added can't be observed by `usePathname` / `useSearchParams` either.

With the flag enabled the pushState/replaceState calls are instrumented and is synced into the Next.js router. This way the Next.js router's internal metadata is preserved, making back navigations apply still, and pathname / searchParams is synced as well, making sure that you can observe it using `usePathname` and `useSearchParams`.

## How?

- Added a new experimental flag `windowHistorySupport`
- Instruments `history.pushState` and `history.replaceState`
	- Triggers the same action as popstate (ACTION_RESTORE) to sync the provided url (if provided) into the Next.js router
	- Copies the Next.js values kept in history.state so that they are not lost
	- Calls the original pushState/replaceState

~~Something to figure out is how we handle additional pushes/replaces in Next.js as that should override the history state that was previously set.~~
Went with this after discussing with @sebmarkbage:
- When you open a page it preserves the custom history state
	- This is to solve this case: when you manually `window.history.pushState` / `window.history.replaceState` and then do an mpa navigation (i.e. `<a>` or `window.location.href`) and the navigate backwards the custom history state is preserved
- When you navigate back and forward (popstate) it preserves the custom history state
- When you navigate client-side (i.e. `router.push()` / `<Link>`) the custom history state is not preserved
2023-11-13 13:32:08 +00:00
Luis Henrique Mulinari
76da32e43f
fix(WellKnownErrorsPlugin): avoid compilation warnings array with empty items (#57768)
Currently, when a webpack compilation warning is processed by
`WellKnownErrorsPlugin` and it's indeed a well know error that should be
bypassed, the warning item is simply deleted from the array, which will
produce an array with empty items:

Example:
```js
{
  client: {
    loading: false,
    totalModulesCount: 2172,
    errors: null,
    warnings: [ <1 empty item> ]
  },
  server: {
    loading: false,
    totalModulesCount: 2119,
    errors: null,
    warnings: [ <1 empty item> ]
  },
  edgeServer: {
    loading: false,
    totalModulesCount: 58,
    errors: null,
    warnings: null
  },
  trigger: undefined,
  amp: {}
}
```

This array with empty items generates a side effect on the [build
output](3553c6516d/packages/next/src/build/output/store.ts (L124)),
since the `warning` array has empty items:

```
➤ npm run dev

> next dev

   ▲ Next.js 14.0.1-canary.3
   - Local:        http://localhost:3000
   - Environments: .env.development

 ✓ Ready in 2.6s
 ✓ Compiled /middleware in 109ms (58 modules)
 ○ Compiling /(dashboard)/page ...
 ⚠


 ⚠
```
![CleanShot 2023-10-30 at 13 20
42@2x](https://github.com/vercel/next.js/assets/33168/fd25bc72-61d6-4446-83cb-87768d5135dd)


This PR solves this issue by removing the `warning` item using the
`Array.prototype.splice`, which removes the item instead of making the
array position empty.

Related PR: https://github.com/vercel/next.js/pull/57073

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
2023-11-13 12:48:44 +01:00
MadCcc
2e82ca8111
fix: import antd from es in modularizeImports (#57968)
### Fixing a bug

Currently any imports from antd will be replaced with `lib`, which will cause context not the same.

Ref: https://github.com/ant-design/ant-design/issues/45567
2023-11-13 03:31:29 +00:00
Lee Robinson
a01beafddd
docs: Update runtime table (#58361)
Adds a bit more clarity that while the edge runtime certainly enables
faster startups than the Node.js runtime (by being in general lighter),
it does not mean the additional user code added will not affect the boot
time. Hello world might be instant but I believe "low" better reflects
that it _will_ grow with user code added.
2023-11-12 19:28:15 -06:00
vercel-release-bot
d7ade76ef8 v14.0.3-canary.5 2023-11-12 23:22:46 +00:00
Joram van den Boezem
44ec398d4b
chore(docs): fix typo (#58344)
Fix typo in markdown link in "Environment variables" docs article

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-11-12 12:15:21 -06:00
Jiwon Choi
022cb25640
fix(eslint): next/script beforeInteractive gives warning on appDir (#51148)
## Issue

The `context.getFilename()` gets the absolute path of the files, and the if statement to filter `/src` and `/app` was not working since #46609.

## Expected

Do not show a lint warning if use `beforeInteractive` inside `appDir`.

Fixes #46609 #50261
2023-11-12 09:30:10 +00:00
vercel-release-bot
a794e1f32e v14.0.3-canary.4 2023-11-12 08:17:33 +00:00
Andrew Clark
b425b40aac
Replace custom Thenable type with native Promises (#58337)
Next.js's implementation includes a custom Thenable type based on a
similar one used in React's codebase. It was used to implement a
userspace equivalent of the React.use API before that API became stable,
by throwing a promise-like object and tracking the status on an expando
field. However, it didn't cover all the same cases and behaviors that
React.use does, which led to some subtle bugs like the one fixed by
@ztanner in https://github.com/vercel/next.js/pull/55690.

Now that React.use is stable, and we use that for suspending instead of
throwing a promise, we no longer need our custom Thenable type. I've
removed the type and associated functions, and updated our types to use
Promise instead.

Even in cases where a function does return a thenable-object rather than
a native promise, like React Flight's createFromFetch, we should use
TypeScript's built-in PromiseLike utility. Currently, though, we always
await these objects anyway (in fetch-server-response.ts), which turns
them into promises. So Promise is almost always sufficient.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 08:45:43 +01:00
vercel-release-bot
00f5b5e789 v14.0.3-canary.3 2023-11-11 23:23:28 +00:00
Vercel Release Bot
bd2d8a3b23
Update font data (#58317)
This auto-generated PR updates font data with latest available
2023-11-11 00:21:04 +00:00
vercel-release-bot
c74f023b88 v14.0.3-canary.2 2023-11-10 23:21:25 +00:00
YOSHIDA Junki
d1fe4d01c4
[Docs] remove example for router.events as it does not exist (#58286)
Removed router.events example from the document because it does not
exist.

URL:
https://nextjs.org/docs/pages/api-reference/functions/use-router#routerevents

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation
- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: Lee Robinson <me@leerob.io>
2023-11-10 09:21:26 -06:00
Karl Horky
ff257800fc
Remove copying of request headers to response (#58304)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Avoid copying request headers to response

### Why?

Copying request headers to response allows for reflection attacks
https://github.com/vercel/next.js/issues/57410

### How?

Remove the `headers:` property assignment

cc @leerob 

Followup to https://github.com/vercel/next.js/pull/58300

Fixes #57410
2023-11-10 16:14:54 +01:00
Lee Robinson
e50782829b
examples: Update Middleware for CSP (#58300) 2023-11-10 13:55:16 +00:00
Leah
b2c926f7c2
fix(turbopack): support middleware in src (#58218)
### What?

We previously marked `/src/middleware` as a missing page

Fixes #42921

Closes PACK-1926

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-10 14:48:20 +01:00
Tim Neutkens
af2c3f71bf
Update 15-content-security-policy.mdx
Ensures the CSP header is still set on the response.
2023-11-10 14:28:43 +01:00
Tim Neutkens
20ad9ac270
Update 15-content-security-policy.mdx
Removes the passing of headers for the response.
2023-11-10 14:20:33 +01:00
vercel-release-bot
7966eaf0f2 v14.0.3-canary.1 2023-11-10 04:31:01 +00:00
Josh Story
37a1342712
Update React from 746890329 to 0e352ea01 (#58279)
Updates React from 746890329 to 0e352ea01.

- https://github.com/facebook/react/pull/27684
- https://github.com/facebook/react/pull/27665
- https://github.com/facebook/react/pull/27671
- https://github.com/facebook/react/pull/27680
2023-11-10 04:25:07 +00:00
vercel-release-bot
52123ccdbc v14.0.3-canary.0 2023-11-09 23:22:17 +00:00
Leah
25bc6afa1f
fix(ci): exclusion regex now actually works instead of ignoring all tests (#58259) 2023-11-09 21:43:35 +01:00
vercel-release-bot
8eba72f30b v14.0.2 2023-11-09 18:32:59 +00:00
vercel-release-bot
fdd6eb990a v14.0.2-canary.27 2023-11-09 17:45:04 +00:00
Dennis Wilm
fd534fb696
Update 02-app-router-migration.mdx (#58253)
Corrected a link that linked to the wrong page. 

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-11-09 09:09:31 -08:00
Tobias Koppers
a628e6344e
avoid key conflict (#58249)
### What?

gives all elements in the array unique keys

should fix #57709 and fix #57743
2023-11-09 16:44:06 +00:00
Arseny
e2f3059b48
Add a self-hosted shared cache example (#58000)
### What?

This pull request integrates the exemplary setup for a self-hosted Next.js application utilizing Redis as a shared cache storage. The solution supports caching at both the App and Pages routers in default and standalone modes, as well as partial pre-rendering, facilitated by the [`@neshca/cache-handler`](https://github.com/caching-tools/next-shared-cache/tree/canary/packages/cache-handler) package. The package enables customizing cache handlers and replacing the default cache provided by Next.js seamlessly.

### Why?

The motivation behind this pull request is to provide an example demonstrating how Redis can be used as a shared cache in a self-hosted environment, thereby improving the scalability of hosting multiple instances of a Next.js application.
2023-11-09 14:29:11 +00:00
Lee Robinson
0cdddd419f
docs: update analytics docs for useReportWebVitals (#58196)
[This
page](https://nextjs.org/docs/app/building-your-application/optimizing/analytics)
was not yet mentioning `useReportWebVitals`.

Closes https://github.com/vercel/next.js/issues/57715.
2023-11-09 13:36:33 +01:00
Jimmy Lai
4024b25e8c
parallel routes: fix catch all route support (#58215)
This PR fixes a bug where parallel routes would not apply appropriately on navigation when used within slots.

The following scenarios:
```
/foo
   /bar
   /@slot
     /[...catchAll]
```

or 

```
/foo
  /[...catchAll]
  /@slot
     /bar
```

will now function correctly when accessing /foo/bar, and Next.js will render both /bar and the catchall slots.

The issue was that the tree constructed by `next-app-loader` for a given path, /foo/bar in the example, would not include the paths for the catch-all files at build time. The routing was done 1-1 when compiling files, where a path would only match one file, with parallel routes, a path could hit a defined path but also a catch all route at the same time in a different slot.

The fix consists of adding another normalisation layer that will look for all catch-all in `appPaths` and iterate over the other paths and add the relevant information when needed.

The tricky part was making sure that we only included the relevant paths to the loader: we don't want to overwrite a slot with a catch all if there's already a more specific subpath in that slot, i.e. if there's /foo/@slot/bar/page.js, no need to inject /foo/@slot/bar/[...catchAll]. 

One thing that is not supported right now is optional catch all routes, will add later.

fixes #48719
fixes #49662
2023-11-09 10:11:06 +00:00
vercel-release-bot
b740fe8fa4 v14.0.2-canary.26 2023-11-09 09:56:42 +00:00
Tobias Koppers
bf966e370e
update turbopack (#58243)
* https://github.com/vercel/turbo/pull/6399 
* https://github.com/vercel/turbo/pull/6393 
* https://github.com/vercel/turbo/pull/6403 
* https://github.com/vercel/turbo/pull/6404 
* https://github.com/vercel/turbo/pull/6394 
* https://github.com/vercel/turbo/pull/6405 
* https://github.com/vercel/turbo/pull/6351
2023-11-09 09:52:22 +00:00
OJ Kwon
51fec997f7
refactor(next-core): apply correct url rewrite behavior (#58237)
### What

Apply correct url rewrite behavior in the specific context (pages/api). 

This won't change anything yet, but it will prevent breaking changes when turbopack makes future changes.
2023-11-09 06:30:37 +00:00
Rich Haines
bbb730e5ef
[Docs]: Fix CLI link to server actions size limit docs (#58174)
This PR fixes the terminal link to server actions size limitations for body size limit. The link is wrong and sending people to a 404
2023-11-09 02:51:14 +00:00
vercel-release-bot
fd7ea115b5 v14.0.2-canary.25 2023-11-09 02:36:39 +00:00
Josh Story
eb79555827
Updated React from 7508dcd5c to 746890329 (#58233)
Updated React from 7508dcd5c to 746890329.

- https://github.com/facebook/react/pull/27674
2023-11-08 18:30:45 -08:00
Zack Tanner
bcef6d6ab6
fix ppr test flake (#58232)
Wraps this test in a `check` since the experimental log seems to occasionally come in late ([x-ref](https://github.com/vercel/next.js/actions/runs/6805954994/job/18506429726#step:27:410))
2023-11-09 02:13:21 +00:00
Sebastian Markbåge
c47c2feb01
Fix test (#58228)
This phrasing was changed.
2023-11-08 20:04:35 -05:00
Zack Tanner
db275073d4
pass postpone through staticGenerationStore (#58229)
Instead of requiring React in `maybePostpone` (which is susceptible to referencing the wrong version of React during build time, such as in the case where the static worker patches fetch within an app-route, which doesn't have an experimental runtime), this provides the postpone API to the `staticGenerationStore`. That way we know the API is available in render which is when we'd expect to postpone.
2023-11-09 00:59:05 +00:00
vercel-release-bot
b50090bf96 v14.0.2-canary.24 2023-11-08 23:21:44 +00:00
Sebastian Markbåge
2f68e62d30
Reword PPR caught bail out to avoid "postpone" terminology (#58223)
The "postpone" terminology is internal to React and can be used for more
things than just this. It's also a mechanism we may or may not rely on.

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-08 17:08:24 -05:00