Commit graph

18690 commits

Author SHA1 Message Date
Zack Tanner
8395059d33
verify action id before parsing body (#58977)
### What?
When handling a server action, in the non-progressive enhanced case,
React will attempt to parse the request body before verifying if a valid
server action is received. This results in an "Error: Connection Closed"
error being thrown, rather than ignoring the action and failing more
gracefully

### Why?
To support progressive enhancement with form actions, the `actionId`
value is added as a hidden input in the form, so the action ID from the
header shouldn't be verified until determining that we've reached the
non-PE case. ([React
ref](https://github.com/facebook/react/pull/26774)). However, in
https://github.com/vercel/next.js/pull/49187, support was added for a
URL encoded form (which is not currently used, as indicated on the PR).

Despite it not being used for server actions, it's currently possible to
trigger this codepath, ie by calling redirect in an action handler with
a 307/308 status code with some data in the URL. This would result in a
500 error.

### How?
React should not attempt to parse the URL encoded form data until after
we've verified the server action header for the non-PE case.

x-ref NEXT-1733
[Slack
context](https://vercel.slack.com/archives/C03S8ED1DKM/p1700674895218399?thread_ts=1700060786.749079&cid=C03S8ED1DKM)
2023-11-29 19:55:00 +00:00
Zack Tanner
77f8889b7c
use 303 status code for redirects in fetch actions (#59017)
### What?
A `redirect` that occurs during a fetch action will get a status code of
200, while the redirection logic is handled client-side.

### Why?
In this scenario, the redirect is handled by the client router, so no
`Location` is set on the action response. However for debugging /
logging purposes, it'd be useful to still return the same status code
used in other cases (see #58885)

### How?
Rather than selectively setting the status to 303 in the non-fetch
action case, this always applies it.

Closes NEXT-1745
2023-11-29 11:45:06 -08:00
Zack Tanner
e8c0273677
add full PPR e2e tests (#59025)
This copies over the E2E tests that were added to `vercel/vercel` in
https://github.com/vercel/vercel/pull/10808 and
https://github.com/vercel/vercel/pull/10823, with some minor adjustments
to reflect the differences in cache behavior between start & deploy.
2023-11-29 11:34:01 -08:00
Tobias Koppers
6b651b0b12
add support for instrumentation (#59070)
<!-- 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 #

-->


Closes PACK-2057
2023-11-29 20:01:38 +01:00
Jimmy Lai
e17b368760
misc: delete kodiak (#59082)
We don't need the auto merging from kodiak since Github has one.

<!-- 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 #

-->


Closes NEXT-1753
2023-11-29 19:38:33 +01:00
vercel-release-bot
cec374f98c v14.0.4-canary.26 2023-11-29 18:34:18 +00:00
Leah
7ce4a02bdc
ci: don't try to upload to datadog for docs only changes (#59068) 2023-11-29 19:25:01 +01:00
JJ Kasper
5b94850d97
Update checkout step (#59079)
When jobs are cancelled we can end up with a bad `.git` tree so this
updates to have a fresh checkout step to avoid this

x-ref:
https://github.com/vercel/next.js/actions/runs/7036193103/job/19148358339?pr=59076
2023-11-29 10:07:22 -08:00
JJ Kasper
7d12945191
Ensure stale build fetch data is not unexpectedly used (#59076)
If a build time fetch cache is present from a previous build we don't
want to unexpectedly use it when flush to disk is set to false in a
successive build as it can leverage stale data unexpectedly.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1701266754905909)

Closes NEXT-1750

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-29 10:03:25 -08:00
Jimmy Lai
9e33bf6ab9
misc: disable automerge (#59077)
Disabling the auto merging behaviour from kodiak. You can queue stuff up
by adding an automerge label though.

<!-- 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 #

-->


Closes NEXT-1751
2023-11-29 18:19:00 +01:00
Leah
72388bc986
fix(test): don't use latest sharp (#59074) 2023-11-29 18:13:58 +01:00
Balázs Orbán
d6d41dc66d
chore: bump nissuer (issue validator) (#59060)
### What?

Bumping the issue validator action [`nissuer`](https://github.com/balazsorban44/nissuer)

### Why?

It introduces two new features:

- Comments made by members of the Vercel organization are never hidden to avoid hiding useful information. Example: https://github.com/vercel/next.js/actions/runs/6780069984/job/18428144215
- A new option was added to do not allow `https://github.com/vercel/next.js.*` URLs as valid reproductions, as they are non-modified versions. We should require the reporter to go through the process of creating an isolated reproduction that we can clone and verify easily.

### How?

See https://github.com/balazsorban44/nissuer/releases/tag/1.8.0
2023-11-29 14:35:26 +00:00
Zack Tanner
eafaba39cb
update status codes for redirect and permanentRedirect in action handlers (#58885)
### What?
Calling `redirect` or `permanentRedirect` with a route handler used by a server action will result in that POST request following the redirect. This could result in unexpected behavior, such as re-submitting an action (in the case where the redirected URL makes use of the same server action).

### Why?
By spec, 307 and 308 status codes will attempt to reuse the original request method & body on the redirected URL.

### How?
In all cases when calling a `redirect` handler inside of an action, we'll return a `303 See Other` response which is a typical status code when redirecting to a success / confirmation page as a result of a POST/PUT.

The other option would be to use 301 / 302 status codes, but since we're already doing a 303 status code [here](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/action-handler.ts#L603), this aligns the behavior for the route handler case. 

Closes NEXT-1733
See also: https://github.com/vercel/next.js/issues/51592#issuecomment-1810212676
[Slack x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1700060786749079)
2023-11-29 08:35:50 +00:00
Lee Robinson
9656f15a48
docs: patch upgrade guide to pin install version (#58993)
Closes https://github.com/vercel/feedback/issues/47076.
2023-11-29 08:26:03 +00:00
Vercel Release Bot
4d55364b7a
Update font data (#59043)
This auto-generated PR updates font data with latest available
2023-11-29 08:08:15 +00:00
Zack Tanner
809164d776
Enable PPR tests for test suites (#59030)
Cherry-picks #58708 without the dependency on https://github.com/vercel/next.js/pull/58779

Co-authored-by: Wyatt Johnson <633002+wyattjoh@users.noreply.github.com>
2023-11-29 03:22:45 +00:00
Tore Lervik
ca19ffb63b
Fixed stale fetch using when page regenerates (#58926)
fixes: #58909
x-ref: #58321, #56472, #56231 

Removed the Math.round of age since it can cause stale fetch data to be
considered not stale if the age rounds downwards. (5.49 is rounded to 5)

Note: This most likely also fixes some bugs with
revalidateTag/revalidatePath. Tested some tag/path issues that got fixed
with this change.
I think this is because revalidatetag/path sets [data.revalidatedAt =
Date.now()](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/incremental-cache/file-system-cache.ts#L120)
for file-system-cache. And with the current code that value would
continue to be "not stale" for up to 0.499 ms.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-28 18:54:31 -08:00
Jiachi Liu
ef3c6490fe
start performance profiling after node.js version is checked (#59028)
Providing better feedback loop for next bindary.

Some users with old node.js version are seeing `performance` is not defined in #57385, we should check the version first.

For compilation, `performace.mark` will also be compiled after those imports since they're hoisted as ESM. This PR moves performance profiling after the `--help` and `--version` processures and node.js version check. So users can see the "upgrade node.js" hint if the node.js version is too old instead of "performance is not defined"
2023-11-29 02:35:06 +00:00
vercel-release-bot
e1a2b12bee v14.0.4-canary.25 2023-11-28 23:22:30 +00:00
vercel-release-bot
266fc8e318 v14.0.4-canary.24 2023-11-28 23:04:45 +00:00
Zack Tanner
298bbe5489
fix async action queue behavior (#59038)
### What?
When the router action queue receives a bunch of async actions in quick succession, some of those requests are dropped, and as a result, anything observing pending transitions will be stuck in a pending state.

### Why?
When adding items to the action queue, the intended behavior is for new actions to be added to the end of the action queue, to be picked up by `runRemainingActions` once the in-flight action is processed. However, new actions are erroneously overwriting pending actions in the queue rather than appending them, as `actionQueue.last` might have a pending action attached to it. 

### How?
This moves the assignment of `actionQueue.last` to always be in `dispatchAction`, rather than the function that processes the action, so that we always have a single spot where `last` is assigned and to prevent it from erroneously omitted/overwritten. 

Fixes #59011
2023-11-28 22:54:04 +00:00
vercel-release-bot
6ac1367687 v14.0.4-canary.23 2023-11-28 22:24:13 +00:00
OJ Kwon
72af59a1c1
build(cargo): bump up turbopack (#59032)
### What?

Bump up turbopack which includes url rewrite related improvements. This makes `test/integration/url` test passes.

Note there are some lacking behavior around edge runtime + url behavior, it is being tracked in PACK-2014.

Closes PACK-2051
2023-11-28 20:42:26 +00:00
JJ Kasper
05f2c68b7a
Increase default timeout for swc build (#59035)
x-ref:
https://github.com/vercel/next.js/actions/runs/7022943529/attempts/3
2023-11-28 12:15:35 -08:00
Dima Voytenko
91471878e1
Testmode: provide test info for rewrite requests (#59033)
The rewrite request appear to bypass the `BaseServer` or are executed in
the sandbox. However, these requests have the correct test info in the
headers that can be used instead of the `AsyncLocalStorage`.
2023-11-28 11:40:15 -08:00
vercel-release-bot
d0c5673d37 v14.0.4-canary.22 2023-11-28 18:26:06 +00:00
Delba de Oliveira
c5acef6150
Docs: Update revalidate example (#59002)
Closing: https://github.com/vercel/feedback/issues/47084

- The example previously showed `export const revalidate` being called
from a `utils` file, whereas we want to call it from a route segment
(layout or page)
2023-11-28 11:20:05 -06:00
Delba de Oliveira
38e9bc9770
Docs: Add missing diagram (#59008)
Slack feedback. Add missing diagram, and polish wording for `layout.tsx`
explanation.
2023-11-28 11:19:05 -06:00
vercel-release-bot
6fd3c3b992 v14.0.4-canary.21 2023-11-28 17:00:46 +00:00
vercel-release-bot
113a125a93 v14.0.4-canary.20 2023-11-28 16:44:35 +00:00
Leah
9c79186610
fix(turbopack): add list of packages that should never be marked as e… (#59020)
### What?

Turbopack was missing the list of modules / requests that should never
be marked as external:

8d1c619ad6/packages/next/src/build/handle-externals.ts (L188)

This could lead to errors with i.e. `next/image` not receiving the
correct image config.

Closes PACK-2047

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-28 17:41:28 +01:00
Wyatt Johnson
f4c14935aa
Cleanup Render Result (#58782)
This improves some of the typings around the `RenderResult` returned during renders. Previously it had a single large metadata object that was shared across both the pages and app render pipelines. To add more type safety, this splits the types used by each of the render pipelines into their own types while still allowing the default `RenderResult` to reference metadata from either render pipeline.

This also improved the flight data generation for app renders. Previously, the promise was inlined, and errors were swallowed. With the advent of improvements in #58779 the postpone errors are no longer returned by the flight generation and are instead handled correctly inside the render by React so it can emit properly postponed flight data.

Besides that there was some whitespace changes, so hiding whitespace differences during review should make it much clearer to review!
2023-11-28 16:10:38 +00:00
Jan Amann
8d1c619ad6
fix: Put back type for NavigateOptions.scroll (#59001)
It seems like in
24b2ff16ab (diff-421107ce62efb02560358d25c5eb086d5d82d2ad1c7c4929ebfb768c2ea1c973)
`forceOptimisticNavigation` was removed, but the `@internal` flag that
was originally assigned to this option remained in place.

Due to this, it seems like `scroll` is missing in the built types (see
[`app-router-context.shared-runtime.d.ts` in the latest
canary](https://unpkg.com/browse/next@14.0.4-canary.18/dist/shared/lib/app-router-context.shared-runtime.d.ts)).

<!-- 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: Zack Tanner <zacktanner@gmail.com>
2023-11-28 07:14:47 -08:00
Zack Tanner
cd66493749
dedupe pending revalidation requests (#58990)
### What?
We currently dedupe fetch requests, but if those fetch requests contain a `revalidate` time, when that window is expired all of those fetches will be invoked without deduping.

### Why?
We track revalidations on the `staticGenerationStore` but we don't have a way to dedupe them, as it's currently just an array. When the (patched) fetch is invoked and catches a stale entry, it'll push each fetch onto the `pendingRevalidates` array which will later be invoked via `Promise.all`. 

### How?
This updates the shape of `pendingRevalidates` to be a map, that way we can reliably dedupe if we see a key that is already pending revalidation. 

Closes NEXT-1744
[slack x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1700836529460289)
2023-11-28 14:38:59 +00:00
OJ Kwon
048ab21f6b
fix(turbopack): treat .mdx as valid ecma asset (#58985)
### What

Pairing with https://github.com/vercel/turbo/pull/6602, enables
ecma-related transform support in mdx. notably fixes test cases in
https://github.com/vercel/next.js/pull/58968 .

With turbopack side fix, still modularize imports are not being applied
as we limite it to .js* extension only. PR expands it to include mdx if
mdx is enabled. PR is failling until turbopack side fix lands.

Closes PACK-2045

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-28 13:54:46 +01:00
Shu Ding
c85caae8d6
Fix encoding in encryption of Server Actions (#59000)
Utils `stringToUint8Array` and `arrayBufferToString` assume that the values are just arbitrary fixed width data. However that doesn't work when we do unicode concatenation (`actionId + arg`) which requires Text encoder/decoder to be used.

Closes #58463, closes #58579. In general any complex unicode characters will cause the same issue, for example emojis.
2023-11-28 10:20:47 +00:00
Tim Neutkens
7bdb61c28d
Fix bugs with baseUrl and mdxRs (#58968)
## What?

Was investigating an issue with Turbopack and MDX, in the process found
a few bugs:

- When you have a `tsconfig.json` or `jsconfig.json` the `baseUrl: '.'`
is used by default which causes the top-level directories to be
available as e.g. `design-system` (without a prefix).
- This is not how TypeScript's default setting for `baseUrl` works.
While it should resolve `paths` relative to `.` when none is specified
it does not do additional resolving for the top level directories/files.
- When `"baseUrl": "."` is added to `tsconfig.js` explicitly it handles
the top level directories.
- `modularizeImports` and other SWC transforms weren't applied to `.mdx`
files when `experimental.mdxRs` is enabled, which caused compilation to
fail.
- `modularIzeImports` and other SWC transforms are not applied to `.mdx`
files when using Turbopack.
	- @kwonoj is investigating this, will be handled in a follow-up PR.

## How?

- Added a test suite for `modularizeImports` with MDX tests
- Removed the condition that disables swcLoader in webpack when using
mdxRs
- Changed the check for `tsconfig.json` / `jsconfig.json` baseUrl to
include if it was implicitly or explicitly set, disabled the module
resolving when it is implicitly set


<!-- 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: Tobias Koppers <tobias.koppers@googlemail.com>
2023-11-28 10:50:14 +01:00
Shu Ding
0d6d53cc26
Code refactoring (#58737)
Saw this pattern when looking at something else. Did a search & replacement. We probably want to setup a lint rule for it.
2023-11-28 09:41:05 +00:00
vercel-release-bot
7ff3e3e32d v14.0.4-canary.19 2023-11-27 23:22:35 +00:00
Jiachi Liu
cdf2b79ea9
Add nodejs version check (#58958)
There're some reports related to using incorrect Node.js version, sometimes users ended up in weird errors. As pkg manager like pnpm only gives a warning ` WARN  Unsupported engine: wanted: {"node":">=18.17.0"} (current: {"node":"v16.18.0","pnpm":"8.9.0"})` which is not easy to investigate the issue.

We're adding a version check at the beginning of the Next.js process so if Node.js version is mis-match the version specified in package.json, bail with error.

Examples

node 16.x
```
You are using Node.js 16.18.0. Node.js >= v18.17.0 is required.
```

node.18.16
```
You are using Node.js 18.16.1. Node.js >= v18.17.0 is required.
```
2023-11-27 16:53:26 +00:00
Andrew Clark
1c5ff6e735
Remove cache field from action types (#58938)
The app router reducer state used to be managed by `useReducer`, so it
was written to be resilient to rebasing — the same action may be
processed multiple times. Now that we've lifted the reducer outside of
React (#56497), each action runs only a single time. So we can simplify
some of the logic.

Previously, actions that update that cache were passed an empty cache
object as part of the action payload. Now, we can instead create these
objects on demand in the reducer.

(We should do the same for the `mutable` object, but there's a unit test
which relies on this implementation detail, so I've left that for a
separate PR.)

<!-- 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-27 11:32:10 -05:00
Andrew Clark
f7459025cf
Delete preloadComponent module (#58741)
We previously used preloadComponent to render nested page/layouts in
parallel, but now that all layouts are passed to React at the top level
(#58669), we no longer need this special module.

A flaw of preloadComponent was that it only called the top-most
component per layout. In the new approach, React can preload non-layout
components, too.

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-11-27 11:31:43 -05:00
Jiachi Liu
46bcd11326
Fix nested fetch logging indentation (#58955)
The indentation of nested logging requests are not correct

### After 

<img height="200" src="https://github.com/vercel/next.js/assets/4800338/4e38cc5e-147c-4f62-81a7-b2a6d84729e0">

### Before
<img height="200" src="https://github.com/vercel/next.js/assets/4800338/5ac8f609-33a9-42b3-9421-291314ab94ba">

reported by @shuding
2023-11-27 15:53:18 +00:00
Zack Tanner
8f2c482729
unify server action detection logic (#58879)
In anticipation of #58885 (and to avoid adding another spot where we're checking the same headers), this unifies the logic that parses the request headers and determines if the request corresponds with a server action.

There was already some drift between the check in `base-server` and `action-handler` (unsure if this was intentional - let me know if so, in which case maybe separated handling is the better approach. I couldn't think of a good reason why it would be different, though). 

Existing tests should be sufficient for testing this changeset.
2023-11-27 07:29:51 -08:00
Leah
40a6e613fe
fix(windows): workaround for intermittent locks on windows when renaming files (#58835)
### What?

See: https://github.com/libuv/libuv/pull/1981

Closes PACK-1956
Fixes #57581
2023-11-27 16:19:45 +01:00
Zack Tanner
e62c18b89d
remove duplicate util file for redirect status (#58878)
No change in behavior, this just moves a util that performs the same
error digest parsing into the other file that performs similar behavior
& validation. Since splitting & parsing the digest string is a strange
operation, this keeps it close to where that happens & where it's
validated so it's easier to follow.

Since this file is imported in the same spots that we're importing the
other redirect utils, there doesn't seem to be a reason to keep them
separated.
2023-11-27 06:58:05 -08:00
Tobias Koppers
f1511515fd
Trace server updates (#58694)
### What?

some refactoring updates


Closes PACK-1994
2023-11-27 15:29:41 +01:00
Donny/강동윤
8e6d51f4fa
Update swc_core to v0.86.81 (#58517)
### What?

Update swc crates.

Diff:
09b3003e58...c566b73bfb

### Why?

To fix bugs, and improve minification.

### How?

turbopack counterpart: https://github.com/vercel/turbo/pull/6472

- Closes PACK-1972

- Closes #30802

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-27 11:02:25 +01:00
Tobias Koppers
4d330a8500
add NEXT_TRIGGER_URL env var to show request triggering a compilation (#58762)
### What?

Shows the actual request url that triggered a compilation in the console
message

### Why?

makes it easier to find accidental compilation

### How?



Closes PACK-2017
2023-11-27 09:14:20 +01:00
vercel-release-bot
7874ad2659 v14.0.4-canary.18 2023-11-26 23:21:26 +00:00