- 22 Jan, 2026 15 commits
-
-
nextjs-bot authored
-
Tim Neutkens authored
## What? This PR fixes font preloading for MDX pages in Turbopack and adds an e2e test to verify the fix. ## Why? When using `next/font` with MDX pages, font preloading was failing with Turbopack because the LoaderTree was storing the **transformed module path** instead of the **original source path**. ## The Bug In Turbopack, MDX files are transformed by adding a `.tsx` extension: - Source file: `app/page.mdx` - After transform: `app/page.mdx.tsx` The `create_module_tuple_code` function in `base_loader_tree.rs` was using `module.ident().path()` (the transformed path) instead of the original `path` parameter. This caused a mismatch at runtime: - Font manifest key: `[project]/app/page` - LoaderTree stored: `[project]/app/page.mdx.tsx` - After stripping `.tsx`: `[project]/app/page.mdx` - **No match** → fonts not preloaded ## The Fix Changed `crates/next-core/src/base_loader_tree.rs` to use the original source path: ```rust // Before let module_path = module.ident().path().to_string().await?; // After let module_path = path.value_to_string().await?; ``` Now the LoaderTree stores `[project]/app/page.mdx`, which after stripping `.mdx` at runtime becomes `[project]/app/page`, matching the font manifest key. ## Test Added `test/e2e/app-dir/mdx-font-preload/` which verifies: 1. MDX page renders correctly 2. Font class from layout is applied 3. Font is correctly preloaded ## How I tested these changes ```bash pnpm test-start-turbo test/e2e/app-dir/mdx-font-preload/mdx-font-preload.test.ts ``` --------- Co-authored-by:Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
-
Tim Neutkens authored
### What? This PR fixes `create-next-app` update notifications for prerelease versions by checking against the correct npm dist-tag. ### Why? Users running `pnpx create-next-app@canary` were incorrectly prompted to update to the stable version because: 1. The `update-check` library queries npm's `latest` dist-tag by default 2. Version comparison using `localeCompare` considers `16.1.1-canary.32` less than `16.1.3` (since base version `16.1.1 < 16.1.3`) 3. This incorrectly triggered an update notification ### How? Instead of skipping the update check entirely for prerelease versions, this PR: 1. Extracts the dist-tag from the current version (e.g., `canary` from `16.1.1-canary.32`) 2. Passes this as the `distTag` option to `update-check` 3. Updates the suggested command to include the correct tag (e.g., `pnpm add -g create-next-app@canary`) This ensures: - Stable users are notified about newer stable releases - Canary users are notified about newer canary releases - Beta/RC users are notified about newer versions of their respective channels Co-authored-by:Cursor Agent <cursoragent@cursor.com>
-
Tobias Koppers authored
Rebase of https://github.com/vercel/next.js/pull/87291
-
Sebastian "Sebbie" Silbermann authored
-
Sebastian "Sebbie" Silbermann authored
https://github.com/user-attachments/assets/0594744b-5dd5-4550-90b8-77071962f666 See [overflow-wrap docs](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/overflow-wrap) for break-word vs anywhere. Just a one-line CSS change. The other changes are renaming functions to disambiguate source/codeframe and the filename.
-
Jiachi Liu authored
-
Matt Mastracci authored
# What? Fix some unimportant `check` warnings that appear as noise in the build logs.
-
Wyatt Johnson authored
### What? Adds a new Claude Code skill `/update-docs` that guides maintainers through updating Next.js documentation based on code changes. ### Why? To help ensure PRs include complete and accurate documentation updates by providing a structured workflow, code-to-docs mappings, and quick reference materials for Next.js doc conventions. ### How? The skill includes: - Main workflow in `SKILL.md` with step-by-step guidance for analyzing changes, updating docs, and scaffolding new feature documentation - `references/DOC-CONVENTIONS.md` - Complete frontmatter schema, code block formatting, and MDX component usage - `references/CODE-TO-DOCS-MAPPING.md` - Maps source code directories to their corresponding documentation paths ### Usage **Manual invocation:** ``` /update-docs ``` **Automatic triggers** - the skill activates when you mention: - "update documentation for my changes" - "check docs for this PR" - "what docs need updating" - "sync docs with code" - "scaffold docs for this feature" - "document this feature" - "review docs completeness" - "add docs for this change" - "what documentation is affected" - "docs impact" - References to `docs/`, `docs/01-app`, `docs/02-pages`, or `.mdx files`
-
Luke Sandberg authored
Adopt the new generated accessor methods in turbo-tasks-backend. Remove the CachedDataItem enum and related support macros. This new approach is more ergonomic, memory efficient, and generates slightly smaller serialized payloads. From measuring vercel-site: ``` canary@e05510ab3bf91c02c7381e2c471363561ffa1198: $ hyperfine -p 'rm -rf .next' -w 2 -r 10 'pnpm next build --turbopack --experimental-build-mode=compile' Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile Time (mean ± σ): 55.981 s ± 0.885 s [User: 386.683 s, System: 111.484 s] Range (min … max): 54.438 s … 57.723 s 10 runs ``` ``` 01-09-migrate-to-typed-accessors@d343fad5bf92af9c5271c62a24aedcf02c3d83d4 $ hyperfine -p 'rm -rf .next' -w 2 -r 10 'pnpm next build --turbopack --experimental-build-mode=compile' Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile Time (mean ± σ): 54.897 s ± 0.496 s [User: 389.400 s, System: 127.353 s] Range (min … max): 54.298 s … 55.681 s 10 runs ``` so a small savings of a little over a second. Not too bad for mostly removing a bunch of `match` expressions that were required in the old model. similarly we should expect a small progression in disk size since we no longer explode into `Vec<CachedDataItem>` which induces some overhead from redundantly encoding enum descriminents and not being able to 'length prefix' collections. from a clean `.next` dir on vercel-site, and a production build with caching enabled, the cache size is before ``` $ du -h .next/cache 4.3G .next/cache/turbopack/v16.1.0-canary.0-518-ge05510ab ``` after ``` $ du -h .next/cache 4.1G .next/cache/turbopack/v16.1.0-canary.0-546-gd343fad5bf92 ``` Which is expected, the main thing we are winning in terms of cache size is the CachedDataItem descriminent values, and in this build we were serializing about 260M items, so we save 1 byte for each of them. In some measurements i saw much more dramatic wins of >1gb, which i do not have a great explanation for.
-
Benjamin Woodruff authored
Turbopack: Use webpki-root-certs in addition to rustls-platform-verifier on Linux for bare-bones Linux images without root CA stores (#88869) This should fix the user-reported issue here: https://github.com/vercel/next.js/pull/88290#issuecomment-3762940063 That issue occurs when building with bare-bones docker images that contain no root CA store. It's inconvenient to test inside of a bare-bones docker image, but I did at least test this works on a normal (Debian) Linux install when fetching fonts for shadcn-ui.
-
Luke Sandberg authored
## What Replace `InnerStorage` with `TaskStorage` generated by the new derive macro from #88338 . Extend the TaskStorage derive macro to generate `CachedDataItem` adapter methods on the `TaskStorageAccessors` trait so we can maintain API compatibility. Replace the serialization layer to use the native TaskStorage representations now that CachedDataitem is only used for API access ## Why TaskStorage will enable more performant serialization and access patterns. From testing on vercel-site this saves ~1% of persistent cache size. For this PR there is no benefit to access pattern performance (in fact i would anticipate a small regression due to the adaptor layer) ## How 1. **Extended macro attribute parsing** - Added `variant`, and `key_field`` attributes to specify CachedDataItem variant mapping per field 2. **Generated adapter methods on TaskStorageAccessors trait**: - `insert_kv(item)` - Insert a CachedDataItem into typed storage - `get(key)` - Look up by CachedDataItemKey - `remove(key)` - Remove by key - `get_mut(key)` - Mutable access (returns None for flags/sets/multimaps) - `iter(type)` - Iterate over a specific variant type - ... This enables current access patterns to keep working 3. **Migrated serialization and deserialization flow**: - use `TaskStorage` throughout the serialization flow using apis like `restore_from` and `clone_data` to create targeted copies for lock free IO. 4. **Removed new dead code** - Delete the `Storage` layer now that it is dead. On its own this will be a small savings in serialized data size (saves 20Mb for vercel-site) and is slightly faster to snapshot/restore. Access performance should be nearly equivalent in performance. -
Benjamin Woodruff authored
Though I've been unable to reproduce the issue (prior PRs in this stack are my attempts at that), I believe this *should* fix the OS Error 80 ([`ERROR_FILE_EXISTS`](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)) that we've seen users report on Windows: https://github.com/vercel/next.js/discussions/88382 Basically instead of deleting the existing link in a retry loop, and then trying to create new new link using a retry loop, we should instead: - Merge these two retry loops into one, in case another process creates the link after we delete it. This shouldn't typically happen, but could theoretically happen. - Extend the retry logic to also retry on [`ErrorKind::AlreadyExists`](https://github.com/rust-lang/rust/blob/503745e9170b40841611aaaa634641edffd00b29/library/std/src/sys/io/error/windows.rs#L19). This might be possible if the filesystem is eventually consistent (which can happen on Windows), but I wasn't able to reproduce this. There's a similar -- but different -- issue that users have been reporting where they get OS Error 1 (`ERROR_INVALID_FUNCTION`) on Windows. I believe this happens if we try to create a junction point on a non-NTFS filesystem. In that case, we need to report a clearer issue to the user instead of bubbling this up as an internal Turbopack error. I tested this on Windows with the symlink fuzzer from #88667, as well as `cargo test -p turbo-tasks-fs`: 
-
Benjamin Woodruff authored
- https://github.com/vercel/next.js/pull/87661 removed the `tokio::task::spawn_blocking` call from `retry_blocking`, so we can simplify things a lot by removing the `Send + 'static` bounds, and eliminate a bunch of cloning `Path`s into `PathBuf`s. - `retry_blocking` no longer takes a path argument. After removing the path cloning requirements, it's now easier for callers to capture paths via a closure, and it's more flexible for IO operations that need to pass in more than a single path. - Adds `retry_blocking_custom`, which I use in #88669 that allows customizing what error kinds we retry on. - Adds documentation to `retry_blocking` explaining why we need this. It's often unclear to new people on the team why we have to retry filesystem operations (Windows, basically). This was unclear to me when I was new to this code, and other people have asked similar questions. - We shouldn't use `Path::display` for error messages or tracing spans. It's easier to use `Debug`, and `Debug` ensures that if the error is related to unicode, that information isn't lost in the error message. - More consistently apply tracing spans using `.instrument`. - Use the modern inline syntax for some format strings. - `let foo = RcStr::from(bar)` is preferred over `let foo: RcStr = bar.into()`
-
Matt Mastracci authored
# What Fixes the `test_mixed_cpu_bound_and_waiting_tasks` to avoid flakes. # Why The `test_mixed_cpu_bound_and_waiting_tasks` was non-deterministic and relied on thread scheduling order. The previous test relied on timing-based synchronization using sleep() calls with varying durations to simulate CPU-bound and async work. This approach was inherently flaky because: 1. Thread scheduling is non-deterministic - a task sleeping for 10ms might complete before one sleeping for 5ms depending on OS scheduler behaviour 2. The assertions depended on specific completion ordering that wasn't guaranteed by the timing 3. Test behaviour could vary based on system load, available cores, and Tokio runtime scheduling # How he new approach uses std::sync::Barrier pairs (start, finish) for each task, giving the test explicit control over when tasks can proceed. Because this is a priority-ordered system, we know which barriers should be available at any given time and can release them. If the given task is not current waiting on its own corresponding barrier, the test will fail.
-
- 21 Jan, 2026 17 commits
-
-
nextjs-bot authored
-
Benjamin Woodruff authored
In an attempt to reproduce https://github.com/vercel/next.js/discussions/88382, this tries creating and updating a bunch of symlinks/junction points in a tight loop with some parallelism. However, I've been unable to reproduce the error reported in that discussion. I don't care about the code quality here, so this was LLM-generated with very lightweight review. A simplified version of the fuzzer is also included as a unit test in `turbo-tasks-fs`. This version only does a few iterations and runs very quickly.
-
nextjs-bot authored
-
Benjamin Woodruff authored
This PR just moves things around for #88667. I don't care about the code quality here, so this was LLM-generated with very lightweight review.
-
Benjamin Woodruff authored
In addition to creating task invalidators for file reads, we also create invalidators for file writes. This extends the fuzzer to cover that. This is a bit trickier to test. Because the `write` call doesn't return anything, the caller of `write` never gets invalidated and re-executed, even though `write` does. So instead, we must observe that `write` was re-executed by looking at the contents of the file it wrote to. We write a sentinel value to files when we call the turbo-tasks-fs `write` function, and write random values to it to trigger an invalidation. I tested this on Windows and Linux. I don't care about the code quality here, so this was LLM-generated with very lightweight review.
-
Matt Mastracci authored
# What Closes https://github.com/vercel/next.js/issues/84782 Closes https://github.com/vercel/next.js/issues/74842 Closes https://github.com/vercel/next.js/issues/82520 Closes PACK-3723 Replace blob URLs for web workers with real entrypoint files, fixing relative URL resolution inside workers. Implements support for `SharedWorkers` since it's now a simple variation of the `Worker` case. Note that all generated files (and shared-worker querystrings) are appropriately content-hashed and do not rely on deployment IDs and will work w/immutable resources. # Why Workers created via `new Worker(new URL('./worker.js', import.meta.url))` previously got blob URLs. This breaks relative URL resolution inside workers - WASM imports like `new URL('./file.wasm', import.meta.url)` fail because `import.meta.url` returns `blob:http://...` instead of a real path. # How We emit a real worker entrypoint file instead of blob URLs. The entrypoint reads bootstrap config from URL hash params (`#params=....`), then loads the worker's chunks via `importScripts`. The `ChunkingContext` trait gets a new `worker_entrypoint()` method returning a singleton bootstrap asset. Node.js `bail!`s for now but could implement its own in the future. The browser implementation (`EcmascriptBrowserWorkerEntrypoint`) compiles and minifies `worker-entrypoint.ts`, which parses `#params={globals,chunks}` from the URL at runtime. `WorkerLoaderChunkItem` now emits `__turbopack_worker_url__(entrypoint, chunks, shared)` instead of the old blob URL shim. SharedWorker passes `shared=true` which adds a querystring - the browser handles worker identity via URL, so same URL means same instance. Generated code changes (pseudocode): ```javascript __turbopack_export_value__(__turbopack_worker_blob_url__(["chunk1.js", "chunk2.js"])); ``` After: ```javascript __turbopack_export_value__(__turbopack_worker_url__("worker-entrypoint.js", ["chunk1.js", "chunk2.js"], false)); ``` # Notes Webpack doesn't currently correctly support `SharedWorkers`. The e2e test behaves properly in turbopack after this change, but webpack spins up two separate workers where it should only be spinning up one. I generated snapshot tests for workers in the first and last commits to help understand the generated code better. # Testing - Snapshot tests for Worker, SharedWorker, and minified output - E2E tests for WASM loading in workers (`test/e2e/app-dir/worker/`)
-
Zack Tanner authored
When generating PPR fallback shells, a cache miss during warmup was being treated as a dynamic hole, so the warmup render never filled new cache entries. This caused root‑param fallback shells (e.g. `/en/blog/[slug]`) to suspend even though root params were already known. This change always creates a fresh prerender RDC for warmup and copies any seed hits into it. The final render then uses the warmed cache, so fallback shells can reuse populated entries without short‑circuiting. On the export side, we now choose a seed RDC by matching known params (e.g. locale) so /en/... fallback shells don’t get seeded with /fr/... data. (Previously, the RDC seed was "last-write-wins". Fixes NAR-716
-
nextjs-bot authored
-
Hendrik Liebau authored
When deployed, the sentinels where showing `at runtime` instead of `at buildtime`. There are two reasons for this: 1. The page sentinel was accidentally rendered in a client component, which causes a hydration mismatch, and the value toggling from `at buildtime` to `at runtime` when the page is hydrated before the assertion is done. 2. The middleware was setting sentinel cookies that are intended for the `/cookies/*` pages, but not for the `/server-action-inline` page. This caused the server action (which is triggered in the second test) to consider the page as revalidated, which then led the client router to refetch the page. With `next start` this is not a problem because the RSC response is prerendered at build time, and returned as a static file, which contains the correct sentinel values. However, when deployed on Vercel, the RSC request results in an ISR cache miss for some reason, which causes the page to be revalidated (with runtime sentinel values), and then the third test fails when it receives the regenerated response instead of the build-time prerender result. This needs to be investigated separately, but for now we disable the middleware from setting cookies on this page to prevent the ISR revalidation request. closes #88817 closes NAR-740 > [!TIP] > Best reviewed with hidden whitespace changes.
-
Tobias Koppers authored
### What? Improve the feature flag to show compressed size
-
Hendrik Liebau authored
The recent change to always run all tests without aborting on failure (#88435) inadvertently broke manifest generation. Previously, test output was emitted for all tests when `NEXT_TEST_CONTINUE_ON_ERROR` was set, but that variable was removed. Now test output is only emitted for failing tests, causing the manifest to lose all passing test entries. This adds a new `NEXT_TEST_EMIT_ALL_OUTPUT` environment variable that restores the full output behavior specifically for the manifest generation workflows.
-
Niklas Mischkulnig authored
-
Tobias Koppers authored
### What? Use amortized shrinking. Capacity should always be a power of 2. We shrink when len is capacity / 3. Assuming the capacity was `2^x` we shrink to `2^(x-1)` which is `capacity / 2`. Therefore capacity is still larger than len, which avoids direct reallocation when items are added again.
-
Niklas Mischkulnig authored
-
Hendrik Liebau authored
-
Andrew Clark authored
This change adds infrastructure for a planned client-side optimization where the router can infer route structure from previously prefetched routes, avoiding redundant route tree requests. When the client prefetches /blog/post-1 and learns the route structure is /blog/[slug], it could potentially reuse that knowledge for /blog/post-2 without another server roundtrip. However, if a static route like /blog/featured exists at the same level, the client needs to know NOT to apply the dynamic template for that URL. staticSiblings provides this information. When a dynamic segment like [slug] has static siblings (e.g., "featured", "archive"), the server includes them in the prefetch response. The client can then check whether an incoming URL matches a known static sibling, and if so, recognize that the previously learned route structure does not apply.
-
Andrew Clark authored
During a Full prefetch (`<Link prefetch={true}>`), check the bfcache for matching segment data before issuing a new request. The bfcache stores data from previous navigations, which always includes dynamic data. This optimization avoids redundant server requests when the user has already navigated to a route and the data is still fresh according to the staleTimes.dynamic configuration.
-
- 20 Jan, 2026 8 commits
-
-
nextjs-bot authored
-
Zack Tanner authored
When digging into failing deployment tests, I often will re-run the test itself without wanting to change anything about Next.js or the test application, especially when I suspect a logic bug in the test itself or need to figure out what's causing a flake. This adds an environment variable that can be used to skip the build/deploy step and will use an existing deployment URL to run the tests against. I suggest reviewing this [without whitespace](https://github.com/vercel/next.js/pull/88829/changes?w=1).
-
Benjamin Woodruff authored
This is a crappy fuzzer I have to make sure that the filesystem watcher picks up changes to files. This didn't have coverage for links, so this tests that. I tested this on Windows and Linux. I don't care about the code quality here, so this was LLM-generated with very lightweight review.
-
Sebastian "Sebbie" Silbermann authored
Part of https://linear.app/vercel/issue/NAR-719/ We previously only supported a single manifest for filtering tests. However, Cache Component deploy tests have two manifests. Now we merge manifests append-only. ## Test plan - [x] https://github.com/vercel/next.js/pull/88821 adds a failed deploy test to a test suite also listed in the CC manifest. Tests from CC and deploy manifest are skipped ```console $ NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json,test/cache-components-tests-manifest.json" NEXT_TEST_MODE=deploy node run-tests.js -c 1 --retries 0 test/e2e/app-dir/searchparams-reuse-loading/searchparams-reuse-loading.test.ts ○ skipped should re-use loading from "full" prefetch for param-full URL when navigating to param-less route ○ skipped should re-use loading from "full" prefetch for param-less URL when navigating to param-full route ○ skipped should re-use loading from "full" prefetch for param-full URL when navigating to param-full route when aliasing is skipped ✕ should work for not found pages ✕ should work for route handlers ✕ should work for navigating to pages dir Without Middleware ✕ should correctly return different RSC data for full prefetches with different searchParam values With Middleware ○ skipped should correctly return different RSC data for full prefetches with different searchParam values ```
-
Jiachi Liu authored
-
Niklas Mischkulnig authored
We don't inline `process.env.NEXT_DEPLOYMENT_ID` anymore into browser chunks, and instead read it from `<html data-dpl-id` attribute at runtime. Closes PACK-6538 - [x] ~~Causes a hydration error at the moment.~~ Solved by removing the attribute immediately before hydration happens <img width="1443" height="620" alt="Bildschirmfoto 2026-01-20 um 12 32 06" src="https://github.com/user-attachments/assets/b69b3a0b-129d-44f4-84d1-10572b650437" />
-
Niklas Mischkulnig authored
Closes PACK-6539 When `experimental.runtimeServerDeploymentId` is enabled, read the `process.env.NEXT_DEPLOYMENT_ID` and append to the chunks when evaluating the `client-reference-manifest.js` Originally, I tried to do it after the manifest is loaded (in `loadComponents` or in the `RouteModule.prepare`) to "hydrate" the manifest, but that is too late because the manifest needs to be initialized immediately to make module-evaluation-time server actions work (which need the manifest immediately)
-
Tobias Koppers authored
- Adds a `process.env.NEXT_DEPLOYMENT_ID` -> `globalThis.NEXT_DEPLOYMENT_ID` replacement - On startup, `globalThis.NEXT_DEPLOYMENT_ID` is initialized to `process.env.NEXT_DEPLOYMENT_ID_COMPILE_TIME` This prepares for https://github.com/vercel/next.js/pull/88761 to replace `process.env.NEXT_DEPLOYMENT_ID_COMPILE_TIME` with reading `<html data-dpl-id>` so that we can remove the env var inlining However, all of this is only done for Turbopack, because we cannot forward `globalThis.NEXT_DEPLOYMENT_ID` to web workers with Webpack easily.
-