- 20 Mar, 2024 1 commit
-
-
vercel-release-bot authored
-
- 19 Mar, 2024 4 commits
-
-
Zack Tanner authored
Updates React from 60a927d04 to 4b84f1161. ### React upstream changes - https://github.com/facebook/react/pull/28585 Closes NEXT-2865
-
JJ Kasper authored
-
Jiachi Liu authored
x-ref: https://github.com/vercel/next.js/actions/runs/8344655954/job/22838765632?pr=63476 We saw the playwright execution was broken while accessing url in turbopack tests. Switching the order to check the content first solve the problem Closes NEXT-2867
-
Zack Tanner authored
#62980 migrated `examples/basic-css` to use app router. A handful of our create-next-app tests use this example when asserting the correct project files are created, so we were asserting on a pages file existing rather than an app dir page. This PR updates those tests. <!-- 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-2754
-
- 18 Mar, 2024 8 commits
-
-
Zack Tanner authored
### What When a route handler uses an API that opts it into dynamic rendering (such as `no-store` on a fetch), and also specifies a `revalidate` time, the `revalidate` time is ignored and route is treated as fully static. ### Why `revalidate: 0` and `revalidate: false` have different semantic meanings: `false` essentially means cache forever, whereas `0` means it's dynamic. Since `0` is also falsey, the code we have to fallback with a default `revalidate` value for route handlers is incorrectly not marking the route as dynamic, and as a result, caching the route without an expiration time. ### How This updates the fallback handling for app routes respect a revalidation value of `0`, so that the page can properly be marked dynamic. ### Test Explanation This adds 2 new routes handlers: both have a revalidation time specified & use `no-store` on a fetch, but only one of them specifies `export const dynamic = 'force-static'`. The one that doesn't specify `force-static` is correctly omitted from the prerender manifest. The one that is `force-static` is correctly in the prerender manifest with the right expiration time. An additional test case was added to verify that this data refreshes after the specified interval. Closes NEXT-2764
-
Zack Tanner authored
### What When triggering an MPA navigation (also commonly referred to as a "hard navigation"), and then restoring the previous page via the browser's bfcache, subsequent requests to the same link wouldn't navigate until reloading the page or performing a different navigation. ### Why MPA navigations in app router are handled in a fairly unconventional way: the router state is updated with an indication that an external URL was clicked, and once the router sees the pending navigation, it kicks off a `location.replace` or `location.push` with the specified URL **in render**. The router then suspends indefinitely to prevent committing the render. However, the router will only make the `replace`/`push` request if there's not already a pending navigation to that same URL. The pending check is needed to avoid continuously calling `push`/`replace` when unrelated router state changes occur (for example, if I hover over a link and trigger a prefetch action and the router re-renders, it shouldn't make another `location.push` call to the same URL that's pending) However, the source of the bug is that the variable that holds this pending state is also restored by the browser's cache, since it takes a snapshot prior to exiting the page. This means that when clicking the browser back button, `pendingMpaPath` would still be set to the URL we just came from. When clicking the link again, it would see that the requested URL is the same as the pending URL, and not perform any history actions. ### How This clears the pending value when the router is restored from bfcache. <!-- 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 # --> [slack x-ref](https://vercel.slack.com/archives/C0676QZBWKS/p1710169967246929) Closes NEXT-2781 Closes NEXT-2776
-
Tim Neutkens authored
Fixes the compile error on all test runs currently: https://github.com/vercel/next.js/actions/runs/8243077904/job/22543375810?pr=63167#step:27:345 The root cause is that `.d.ts` files automatically include inferred return types automatically, in this case `tsc` included React class component `render()` return types in the `.d.ts` for e.g. error-boundary.tsx / redirect-boundary.tsx. This is a problem because yesterday that return type was changed: https://github.com/DefinitelyTyped/DefinitelyTyped/commit/bf659aefa780a8b61b1636bd0296e0723c96d780#diff-1d64e275d9755825ba[…]520436dbd8e1f1fd9fc66a9 and that change also removes one of the previous types that the `.d.ts` in Next.js automatically included. This PR changes the `render()` return type to be explicit instead of inferred, this makes sure that the `.d.ts` file includes only `: React.ReactNode` instead of the many types of return values allowed. The reason I went with the explicit type instead of e.g. upgrading `@types/react` is that upgrading the types would cause existing applications that use older versions of `@types/react` would break. The current change ensures it works in both cases. <!-- 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-2787
-
Jiachi Liu authored
### What Exclude the cases like external urls and relative urls with query from appending trailing slash when it's needed. The process is: - If it's a uncertain string path (relative url, could start with `'./'` or `/`), convert to relative that starts with `/`; - then we covert the url (string or URL) to string url - We do the check if we need to append the trailing slash ### Why In #62109 we added functionality that can only append trailing slash when we appended trailing slash to some metadata url like `canonical` url and open graph url when the config is enabled. For urls with queries, the trailing slash can also be omitted. For the external urls (different origin comparing to `metadataBase`) we don't need to append trailing slash as they're not the same web app. x-ref: [slack thread](https://vercel.slack.com/archives/C0676QZBWKS/p1709845946033929) Closes NEXT-2762 Closes NEXT-2753
-
Steven authored
This PR stabilizes an experimental feature that was added in a previous PR https://github.com/vercel/next.js/pull/50470 It allows the user to set `deploymentId` in `next.config.js`, which is a unique identifier for a deployment that will be included in each request's query string or header. This PR is easier to review with whitespace hidden: https://github.com/vercel/next.js/pull/63198/files?w=1 Closes NEXT-2789
-
Steven authored
- Release notes https://github.com/vercel/nft/releases/tag/0.26.3 - Fixes https://github.com/vercel/next.js/issues/59346 - Related to https://github.com/lovell/sharp/issues/3967 Closes NEXT-2334
-
Ethan Arrowood authored
Follow up to https://github.com/vercel/next.js/issues/61133 that will rely on `x-forwarded-proto` value if it exists in order to default the `x-forwarded-port` value. Closes NEXT-2820
-
Yuval Lotem authored
### What? See this issue - https://github.com/vercel/next.js/issues/61133 following this change https://github.com/vercel/next.js/pull/57815 `x-forwarded-port` header value is 'undefined' if the URL has no port ### Why? x-forwarded-port 'undefined' makes other http-proxy throw 405 error for the invalid header value ### How? Give default 80 port if the URL has no port --------- Co-authored-by:
Ethan Arrowood <ethan@arrowood.dev>
-
- 06 Mar, 2024 6 commits
-
-
vercel-release-bot authored
-
JJ Kasper authored
-
JJ Kasper authored
This upgrades to the latest edge-runtime packages as it includes exposing `performance`. This was reverted previously as our publishes were failing with a specific change that has since been removed upstream. Closes NEXT-2730 # Conflicts: # packages/next/package.json # test/e2e/opentelemetry/app/api/app/[param]/data/edge/route.ts # test/e2e/opentelemetry/pages/api/pages/[param]/edge.ts
-
JJ Kasper authored
This ensures we don't normalize the `distDir` in the webpack config in dev mode as it won't be moved to the right location like it is during build. Fixes: https://github.com/vercel/next.js/issues/61105 Closes NEXT-2495
-
JJ Kasper authored
This moves the locale redirect handling out of `base-server` as it shouldn't be handled here and should be at the routing level. This avoids the duplicate handling with middleware that causes the incorrect detection/infinite looping. Test case from separate PR was carried over to prevent regression. Fixes: https://github.com/vercel/next.js/issues/55648 Closes: https://github.com/vercel/next.js/pull/62435 Closes: NEXT-2627 Closes: NEXT-2628 --------- Co-authored-by:
Nourman Hajar <nourmanhajar@gmail.com> Co-authored-by:
samcx <sam@vercel.com>
-
JJ Kasper authored
-
- 04 Mar, 2024 7 commits
-
-
JJ Kasper authored
-
Jiachi Liu authored
Fixes the string id that broken when sitemap is optimized to static route. When sitemap is optimized to static route in production, the route argument is changed from `[[...__metadata_id__]]` to `[__metadata_id__]`, so the type of it is also changed from array to string that should reflect in the loader code. Fixes #60894 Closes NEXT-2154
-
Abhinay Pandey authored
generateSitemaps function returns a 404 for /sitemap/[id].xml in production While finding the correct sitemap partition from the array, we check the param against the id. Which works in dev because id and param are both without trailing .xml. But it fails in production as param has a trailing .xml (/sitemap/[id] works in production because it falls back to dynamic loading and param and id are both without .xml) If we are in production environment, check the id with a trailing .xml because that's whats returned from generateStaticParams, an array of __metadata_id__ with trailing .xml Fixes #61969 --------- Co-authored-by:Jiachi Liu <inbox@huozhi.im>
-
Jiachi Liu authored
Fixes `redirect()` call under suspense boundary, redirect url should include the `basePath` in the url. `redirect()` under suspense boundaries will go through server html insertion, which is being used every time by suspense boundary resolved, new errors will triggered from SSR streaming. It was missing before. Fixes NEXT-2615 Fixes #62407
-
Shu Ding authored
As mentioned in the new-added error messages, and the [linked resources](https://react.dev/reference/react/use-server#:~:text=Because%20the%20underlying%20network%20calls%20are%20always%20asynchronous%2C%20%27use%20server%27%20can%20only%20be%20used%20on%20async%20functions.): > Because the underlying network calls are always asynchronous, 'use server' can only be used on async functions. > https://react.dev/reference/react/use-server It's a requirement that only async functions are allowed to be exported and annotated with `'use server'`. Currently, we already have compiler check so this will already error: ```js 'use server' export function foo () {} // missing async ``` However, since exported values can be very dynamic the compiler can't catch all mistakes like that. We also have a runtime check for all exports in a `'use server'` function, but it only covers `typeof value === 'function'`. This PR adds a stricter check for "use server" annotated values to also make sure they're async functions (`value.constructor.name === 'AsyncFunction'`). That said, there are still cases like synchronously returning a promise to make a function "async", but it's still very different by definition. For example: ```js const f = async () => { throw 1; return 1 } const g = () => { throw 1; return Promise.resolve(1) } ``` Where `g()` can be synchronously caught (`try { g() } catch {}`) but `f()` can't even if they have the same types. If we allow `g` to be a Server Action, this behavior is no longer always true but depending on where it's called (server or client). Closes #62727.
-
Zack Tanner authored
### What When attaching a rejection listener to a server action promise, in the case of network errors, the rejection handler would be skipped and it'd throw an error that crashes the application. ### Why When we refactored these reducers to no longer suspend, it caused the rejection handling logic we have to no longer make sense. In this case we're working with a native promise that won't have a `status` property, so we'd re-throw the error and not call `reject`. ### How This removes the special status handling logic and makes the rejection handler always call `reject` with the error. This will either be handled by user code or let the error bubble to an error boundary. I also cleaned up some mutable code that is no longer needed now that these reducers aren't replayed. Closes NEXT-1715 Closes NEXT-2323 Fixes #58638
-
Zack Tanner authored
Following an anchor link to a hash param, and then attempting to use `history.pushState` or `history.replaceState`, would result in an MPA navigation to the targeted URL. In #61822, a guard was added to prevent calling `ACTION_RESTORE` with a missing tree, to match other call-sites where we do the same. This was to prevent the app from crashing in the case where app router internals weren't available in the history state. The original assumption was that this is a rare / unlikely edge case. However the above scenario is a very probable case where this can happen, and triggering an MPA navigation isn't ideal. This updates `ACTION_RESTORE` to be resilient to an undefined router state tree. When this happens, we'll still trigger the restore action to sync params, but use the existing flight router state. Closes NEXT-2502
-
- 02 Mar, 2024 3 commits
- 29 Feb, 2024 5 commits
- 28 Feb, 2024 6 commits
-
-
Max Leiter authored
### What? Backports some Server Action changes from Shu to 14.1.1. [Improve the Server Actions SWC transform ](https://github.com/vercel/next.js/pull/62655/commits/bf6460e985c0ff8e41c03e000cbcb2638bcf99c7) [Fix Server Reference being double registered](https://github.com/vercel/next.js/pull/62655/commits/ef81b1099856bc7918dfa39e6d272cce53451eaf) [Improve the Server Actions SWC transform (part 2)](https://github.com/vercel/next.js/pull/62655/commits/6e59c222a84f48edfc958d3327eb5448431e7784) [Fix module-level Server Action creation with closure-closed values](https://github.com/vercel/next.js/pull/62655/commits/51c6a07ec6a373eca3425ef565a53f4105112099) [Rename internal utility naming for clarification](https://github.com/vercel/next.js/pull/62655/commits/00d8e6e0612b7afddbce5f944a7330413e548871) ### Why? ### How? --------- Co-authored-by:
Shu Ding <g@shud.in> Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Jiachi Liu authored
Backport metadata fixes #61898 #62109 #62615 Closes NEXT-2641
-
Ethan Arrowood authored
### What? In today's implementation, requests that don't end in `.rsc` are getting the data request query. We need to remove this toggle to prevent them from 500'ing. ### Why? The invariant triggered was: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/packages/next/src/server/base-server.ts#L2838-L2842 Crawling up the code, the conditional: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/packages/next/src/server/base-server.ts#L2815 must be `true`. The variable `isDataReq` is set here: https://github.com/vercel/next.js/blob/212553958c671ea1f71d96fbc97ea4b9e5019bf3/packages/next/src/server/base-server.ts#L1833-L1839 This conditional expression is a bit complex, but it simplifies down to: - `isDataReq` is `true` when (TODO) - `isDataReq` is `false` when (TODO) ### How? Closes NEXT-2341 Fixes #61377 Tested manually by: - Building and packaging this branch locally - Deploying tarball and then depending on it as the Next.js version for an example app similar to the one reported by #61377 - Inspecting console for 500 errors. --------- Co-authored-by:
JJ Kasper <jj@jjsweb.site> Co-authored-by:
Zack Tanner <zacktanner@gmail.com>
-
Steven authored
The `process/browser` lib was imported and being transformed, but `process.browser = true` turns to `true = true` that causes the compilation error, we need to exclude them from certain compilation layers - Fixes https://github.com/vercel/next.js/issues/61116 Closes NEXT-2410 Closes NEXT-2328 --------- Co-authored-by:
Jiachi Liu <inbox@huozhi.im>
-
Jiachi Liu authored
We have a modularize imports config for `next/server` before, which will transform the `next/server` imports to directly import from the actual file, for instance: `import { NextRequest } from 'next/server'` will become `import { NextRequest } from 'next/dist/server/web/exports/next-request'`, where the NextRequest is exported as default export. This is fine in most case until you're using a ESM pkg, then it will be resolved as `{ default: NextRequest }` according to the spec. Since it's a ESM import to a CJS module in `next/dist`. Since we already have the ESM alias introduced in #59852 , this can handle the case more properly. Remove the modularize imports config for `next/server`, use the ESM api alias instead. Migrate the cjs optimizer tests from middleware to a separate endpoint `/cjs/server`. As now ESM imports for next/server are not going to get tree-shaken in dev, but since we don't have image response there it's still fine. Closes NEXT-2376 Closes NEXT-2374 -
JJ Kasper authored
This ensures we don't do un-necessary IPC calls during image optimizing and leverage the internal request handler for fetching internal static images/resources. x-ref: https://github.com/vercel/next.js/issues/58248 Closes NEXT-2318
-