- 21 Aug, 2024 2 commits
-
-
vercel-release-bot authored
-
JJ Kasper authored
To reduce the number of set requests we were sending upstream we added an optimization to skip sending the set request if the cached data didn't change after a revalidation. The problem with this optimization is the upstream service relies on this set request to know to update the cache entries TTL and consider it up to date. This causes unexpected revalidations while the cache value hasn't changed and the TTL is kept stale. x-ref: NEXT-3693 # Conflicts: # packages/next/src/server/lib/incremental-cache/fetch-cache.ts # test/turbopack-build-tests-manifest.json
-
- 05 Aug, 2024 2 commits
- 02 Aug, 2024 1 commit
-
-
Mark Knichel authored
This makes the Multi-Zones docs available in the live nextjs.org site.
-
- 10 Jul, 2024 1 commit
-
-
vercel-release-bot authored
-
- 09 Jul, 2024 13 commits
-
-
Jiachi Liu authored
-
JJ Kasper authored
Gives us more context when this fails as it is here https://github.com/vercel/next.js/actions/runs/9469195858/job/26087290365#step:15:23
-
JJ Kasper authored
This ensures we always set up turbo to the version we expect even if we're building in docker since the cache is pulled outside of docker. x-ref: https://github.com/vercel/next.js/actions/runs/9484631800/job/26134568488
-
Jiachi Liu authored
backport #65715 into 14.2
-
Tobias Koppers authored
### What? This disallows merging of global css with styles that appear on other pages/chunk groups. ### Why? Before we made the assumption that all CSS is written in a way that it only affects the elements it should really affect. In general writing CSS in that way is recommended. In App Router styles are only added and never removed. This means when a user uses client-side navigations to navigate the application, styles from all previous pages are still active on the current page. To avoid visual artefacts one need to write CSS in a way that it only affects certain elements. Usually this can be archived by using class names. CSS Modules even enforce this recommendation. Assuming that all styles are written this way allows to optimize CSS loading as request count can be reduced when (small) styles are merged together. But turns out that some applications are written differently. They use global styles that are not scoped to a class name (e. g. to `body` directly instead) and use them in different sections of the application. They are structured in a way that doesn't allow client-side navigations between these sections. This should be valid too, which makes our assumption not always holding true. This PR changes the algorithm so we only make that assumption for CSS Modules, but not for global CSS. While this affects the ability to optimize, applications usually do not use too much global CSS files, so that can be accepted. fixes #64773
-
Jiachi Liu authored
### What Add isEdgeRendering check condition for rewrite logic in edge adpator Fixes #66837 Closes NEXT-3545 ### Why From headers `x-middleware-rewrite`, it's still relative url `/rewrite`, reconstructing the url will lead to crash as it doesn't contain host.
-
Steven H authored
This PR introduces a **breaking change** that returns a 400 error if the Image Optimization API is given a protocol-relative URL. The Image Optimization API currently checks whether the given image URL is relative by checking `url.startsWith('/')`. This means that protocol-relative URLs, such as `//example.com`, pass the check and are treated as relative. They in turn skip any kind of validation provided when matching against `remotePatterns` and are passed back to the optimation logic as a relative URL. My knowledge of the stack stops there, but in our case at GitBook it led to a nasty attack where non-GitBook content could be served over this URL: https://docs.gitbook.com/_next/image?url=//example.com&w=1200&q=100 - even though we have configured `remotePatterns` to protect against it. I originally went into the problem wanting to handle the URL properly (treating it as an absolute URL and potentially using the protocol of the Optimization API itself as the relative protocol), but after seeing the code in https://github.com/vercel/next.js/blob/canary/packages/next/src/client/legacy/image.tsx#L135 and https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/image-loader.ts#L26 it feels that protocol-relative URLs are just not really supported anywhere. My understanding is that very few uses of `next/image` will be allowed to use protocol-relative URLs, so the impact of this breaking change should be quite low? If others disagree I am happy to modify and to use the protocol of the request as a stand-in for the relative protocol. --------- Co-authored-by:Steven <steven@ceriously.com>
-
OJ Kwon authored
### What For loading wasm, path interop to absolute file path occurs in here (https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1249) already so shouldn't pre-populate import path when call loading wasm to make internal path operation (https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1247) work.
-
Jiachi Liu authored
Use `addDependency` to track the file path passed to `next-metadata-route-loader` NOTE: We cannot apply the `next-metadata-route-loader` directly to the metatda convention source files, since the json file could be processed by json loader (Related previous fix #62615) Previously when we passed down the file path as argument to the loader, which sort of breaking the caching of webpack as the actual resource path is string, it's not tracked as a dependency. This change fixed the bad caching issue of static metadata routes. Based on the above reason we use `addDependency` here to track the dependency change Closes NEXT-3521 Closes #65755
-
Jiachi Liu authored
Render noindex into a flight data and rsc payload when page path is `/404` When it's static generation, noindex is not rendered due to the statusCode from mock request is 200, but we can relying on the pagePath as `/404` page should always contain `nonidex` We were missing the noindex before for flight generation, now we'll render it when it's 404 page.
-
Steven authored
-
Jiwon Choi authored
Identified the bottleneck of Turbopack HMR, one of the reason is that we run `execSync` to get user's package manager and fetch their registry to get the latest & canary version of Next.js. This process was located at the initial of HMR, which could have been delayed to the initial of the error handling. - Remove getting user's package manager and just fetch from NPM regardless the user uses Yarn. - Used an async IIFE to await the promise of `getVerionInfo` value inside the synchronous `ws.handleUpgrade`. > Benchmarked with console inside try-finally | Version | Ready | |-------------------------------------|---------| | Canary | 1185ms | | Delta | 896ms | | Delta Webpack vs Canary Webpack | -24.39% | | Version | Ready | |-------------------------------------|---------| | Canary | 1002ms | | Delta (Turbopack) | 509ms | | Delta Turbopack vs Canary Turbopack | -49.20% | --------- Co-authored-by:
Jiachi Liu <inbox@huozhi.im> Co-authored-by:
Tobias Koppers <tobias.koppers@googlemail.com>
-
Jiwon Choi authored
cc @icyJoseph @ztanner NOTE: The canary release [`v14.1.1-canary.51`](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.51) and below work as expected. ### Why? Introduced from #61535, the initial prefetch cache is set based on the `location.pathname`. When a page is loaded WITH the search param, the cache key does not contain information of the search param. The issue is when on a dynamic page reading the `searchParams` value, the value doesn't change if navigated as: ``` /?q=foo --> / ``` The prefetch cache hits, not re-rendering, and the `searchParams` value is not passed properly. ### How? For the prefetch cache, add the `location.search` as well. Since `createPrefetchCacheKey` uses [`createHrefFromUrl`](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/router-reducer/create-href-from-url.ts) which includes `location.search`, I'm expecting the change won't affect current cache key behavior. Fixes #64170 Fixes #65030 --------- Co-authored-by:
Zack Tanner <1939140+ztanner@users.noreply.github.com>
-
- 02 Jul, 2024 1 commit
-
-
Donny/강동윤 authored
### What? Backport https://github.com/swc-project/swc/pull/8835. Changes: - `swc_core`: `v0.90.30` => `v0.90.31` - `swc_ecma_transforms_compat`: `0.163.18` => `v0.163.19` ### Why? It fixes a bug of class properties transform. ### How? Fixes #66085
-
- 11 Jun, 2024 7 commits
-
-
vercel-release-bot authored
-
Janka Uryga authored
-
Janka Uryga authored
Closes [#66650](https://github.com/vercel/next.js/issues/66650) Closes NEXT-3520 - Make Link not throw during prefetch if it received an invalid `href` (see [#66650](https://github.com/vercel/next.js/issues/66650)) - Throw in dev mode if an invalid link was passed to `router.prefetch` -- this matches current prod behavior - (previously, we'd immediately exit out of `router.prefetch`, so the user would see no indication that this'd fail in prod) If an invalid URL was passed to `<Link>`, the whole app would crash and show "A client-side exception occurred". A failed prefetch should not bring down the whole app. Note that This preserves the current behavior of explicit `router.prefetch(url)` throwing an error if `url` is invalid. We may want to adjust this in the future, but that could be considered a breaking change, so I'm leaving it out for now. This only affects `Link`, which was intended to catch any errors thrown from `router.prefetch`, but that bit was accidentally broken.
-
JJ Kasper authored
As discussed this adds handling to timeout at a max of 500ms for fetch cache request and retries a max of 3 times due to network instability. This also adds cache service tests and fixes a case we've been trying to track down where we were seeing `undefined` cache URL values which made debugging fetches tricky. # Conflicts: # packages/next/src/server/base-server.ts # packages/next/src/server/lib/incremental-cache/fetch-cache.ts # packages/next/src/server/web/spec-extension/unstable-cache.ts
-
Jiachi Liu authored
Use `addDependency` to track the file path passed to `next-metadata-route-loader` NOTE: We cannot apply the `next-metadata-route-loader` directly to the metatda convention source files, since the json file could be processed by json loader (Related previous fix #62615) Previously when we passed down the file path as argument to the loader, which sort of breaking the caching of webpack as the actual resource path is string, it's not tracked as a dependency. This change fixed the bad caching issue of static metadata routes. Based on the above reason we use `addDependency` here to track the dependency change Closes NEXT-3521 Closes #65755
-
JJ Kasper authored
While investigating unexpected stale responses when leveraging `getStaticProps` on the 404 page noticed we have an inconsistency between local and deployed due to `Cache-Control` being set to `no-store, must-revalidate` even though a revalidate period is provided. The inconsistency also differs between the HTML response and the data response `_next/data` which causes even more unexpected behavior. To avoid this behavior, this replaces the handling to ensure we honor the originally provided revalidate period during `notFound: true` for the `Cache-Control` header. Validated against provided reproduction here https://github.com/fusdev0/next-notfound-revalidate Deployment: https://vercel.live/link/next-notfound-revalidate-govzskknf-vtest314-ijjk-testing.vercel.app/fallback-blocking/fasdf Prior PR for prior context that introduced this https://github.com/vercel/next.js/pull/19165 x-ref: [slack thread](https://vercel.slack.com/archives/C0676QZBWKS/p1717492459342109) # Conflicts: # packages/next/src/server/base-server.ts
-
Karim Shehadeh authored
### What Skip adding trailing slash for file pattern like same origin urls ### Why Fixes #66635 Next.js will not append trailing slash for file like pattern urls when `trailingSlash` is enabled. This PR aligns the behavior of the metadata trailing slash appending with next-server route handling. --------- Co-authored-by:Jiachi Liu <inbox@huozhi.im>
-
- 10 Jun, 2024 2 commits
-
-
Zack Tanner authored
During navigations, the `FlightDataPath` property from the server response can be an array if there are multiple parallel routes (eg, `children` and `slot`). When we apply server response to the router cache, we might call `applyFlightData` for each segment path, which will copy existing cache values and insert new ones depending on what changed. However, the `existingCache` argument that we pass to this function is the cache at the start of the navigation. That means subsequent calls to `applyFlightData` will reference the cache _before_ updates are made to it. This will cause it to erroneously think it needs to lazy fetch for missing data. <!-- 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: - 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 - 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 - 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 - 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 - 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 Closes NEXT- Fixes # -->
-
Zack Tanner authored
When checking which segment(s) need to be refreshed, we currently compare the current page URL with the segment's refresh marker. We should inspect the `mutable.canonicalUrl` value first since that's the URL we're changing to, followed by `state.canonicalUrl` as a fallback (indicating that there's no URL change pending). This is because the server action handler will receive a redirect URL prior to `location.pathname` being updated, so the router will incorrectly think it needs to refresh the data for the page we're going to. Closes NEXT-3500
-
- 06 Jun, 2024 4 commits
-
-
Jiachi Liu authored
Fixes NEXT-3498 Fixed loading shows up and disappear during client navigation, when you defined `prefetch` is enabled and slow `generateMetadata` is defined. In suspense, adding it back so that the app can still remain suspensy during navigation. Prefetch -> Link Navigation -> Show `loading.js` -> RSC payload fetched (no page content) -> the page content will display later when the promise is resolved Prefetch -> Link Navigation -> Show `loading.js` -> RSC payload fetched -> suspensy page content still triggering `loading.js` -> display the resolved page content when the promise is resolved --------- Co-authored-by:Zack Tanner <1939140+ztanner@users.noreply.github.com>
-
Steven authored
In a previous PR, https://github.com/vercel/next.js/pull/47302, detection for `fetchPriority` assumed that https://github.com/facebook/react/pull/25927 would land in react@18.3.0 because that was the react@canary version at the time. However, it didn't land in react@18.3.0 and it is expected to land in react@19.0.0 due to the breaking change. This means that users upgrading to react@18.3.0 will see a warning. The fix is to stop looking at the `React.version` string and instead check for `React.use`, a feature that [will land in react@19.0.0](https://react.dev/blog/2024/04/25/react-19#new-feature-use) but is also available in react@canary and react@beta today. Note: There were tests added for App Router and Pages Router in a previous PR https://github.com/vercel/next.js/pull/47302 but they seem to run on react@18.2.0 which is why we don't see failures. Fixes https://github.com/vercel/next.js/issues/65161
-
Jiachi Liu authored
Leveraging the system env vars for fallback logic x-ref: https://vercel.com/docs/projects/environment-variables/system-environment-variables For preview deployment: prefer using `VERCEL_BRANCH_URL`, fallback to `VERCEL_URL` For production deployment: prefer using `VERCEL_PROJECT_PRODUCTION_URL` Closes NEXT-3237
-
Jiachi Liu authored
### What * Fix `next/dynamic` with babel config and `src/` directory * Separate the existing `next/dynamic` dev tests, make it easier to cover more cases, add `.babelrc` + `src/` folder coverage case ### Why * The new transform is using `src/` or root dir as the base directory `next/dynamic` for generating relative module path as unique key for `next/dynamic` modules. The babel one was always using the root dir (`cwd`), which is incorrect. It should use the `src/` dir. In the future we could make the different solution to generate the unique id simpler, instead of using relative paths Closes NEXT-3254 Closes NEXT-3251 Fixes #64741
-
- 05 Jun, 2024 3 commits
-
-
Will Binns-Smith authored
-
Zack Tanner authored
Properties such as the native `Headers` / `Cookies` on the `NextRequest` proxy make use of internal slots, so passing `receiver` (the proxy object) which does not have the internal slots on it causes an issue in the edge runtime. Instead, we want to make sure that the target is the native object. This is similar to https://github.com/vercel/next.js/pull/47088. <!-- 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: - 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 - 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 - 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 - 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 - 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 Closes NEXT- Fixes # -->
-
Zack Tanner authored
-
- 04 Jun, 2024 2 commits
-
-
Zack Tanner authored
-
Zack Tanner authored
In #60645, dynamic access tracking was refactored but we erroneously stopped tracking dynamic access in route handlers. Request proxying, as well as tracking segment level configs (such as `export const dynamic = 'force-dynamic'`), were only enabled during static generation. This was an unintended breaking change that consequently caused dynamic access to not properly bail from data cache in various circumstances. This adds some more rigorous testing for route handlers, as this seems to be a fairly large gap in our fetch cache testing currently. This PR is easiest to review with [whitespace disabled](https://github.com/vercel/next.js/pull/66446/files?w=1).
-
- 24 Apr, 2024 1 commit
-
-
vercel-release-bot authored
-
- 23 Apr, 2024 1 commit
-
-
JJ Kasper authored
This ensures we only track fetch metrics in development mode as that's the only time we report them currently, this also adds an upper limit on how many metrics we store per-request as previously this was unbounded, on top of that this ensures we don't keep tracking fetch metrics after the request has ended as we only report on request end, and finally this adds a clean-up to the reference we attach to the request object containing the fetch metrics once we have used them. Closes: https://github.com/vercel/next.js/issues/64212 Closes NEXT-3159
-