- 21 Apr, 2025 11 commits
-
-
vercel-release-bot authored
-
Benjamin Woodruff authored
## Why? I'm trying to run https://github.com/boshen/cargo-shear over our workspace to remove unused dependencies. It runs `cargo expand` with `--all-features`, which was breaking on this crate. ## Changes Summary - Add `opt-level = 1` in dev for this crate. - Reduce the iterations used in tests. If we really want tons of iterations, we should use benchmarks or write a fuzzer utility. Unit tests should be small and fast. - Increase the test for blobs to use a 65KiB blob size and assert that's larger than the blob threshold. - Cleanup: Use the more-correct `u32` type for the `family` field in a few more places instead of `usize` and make the numeric representations of the `KeySpace` enum a bit more explicit. ## Prior to these changes - Building with `--features turbo-persistence/verify_sst_content` would fail with compilation errors - Unit tests would take multiple minutes to run - The blob test didn't appear to actually test blobs (10KiB < 64KiB) ## After these changes - The `verify_sst_content` feature works and passes unit tests - Unit tests finish in about a minute with `cargo test` and `cargo nextest`, this is still slow, but much better than it was. - Unit tests actually test blobs as intended.  ## Potential future work It would be useful to be able to adjust the medium and large (blob) size thresholds to allow us to lower those thresholds in tests.
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Turbopack.
-
vercel-release-bot authored
-
Donny/강동윤 authored
### What? - Use `analyze.references()` beacuse we need imports to be in `esm_references`. ### Why? It's identical but cleaner. Closes PACK-4397
-
Wyatt Johnson authored
This pull request introduces changes to enhance the handling of prefetch segment data routes in the Next.js build process and adds new test cases to validate these updates. Key changes include the addition of a new `buildInversePrefetchSegmentDataRoute` utility, modifications to the route generation logic, and the introduction of experimental features like `clientSegmentCache`. This addresses a bug where conflicting routes while incremental PPR was enabled that matched routes incorrectly, for example: ``` /~/monitoring <- PPR disabled /[teamSlug]/monitoring <- PPR enabled ``` Would previously cause client segment requests for `/~/monitoring` to match `/[teamSlug]/monitoring`. This addresses it by adding early rewrites to handle this case. This will be removed in future versions when incremental PPR is deprecated. ### Enhancements to prefetch segment data routes: * Added a new utility, `buildInversePrefetchSegmentDataRoute`, to support inverted prefetch segment data routes, which rewrite from segment paths back to prefetch RSC routes. This is particularly useful for handling dynamic routes without conflicts when partial prerendering is disabled (`packages/next/src/server/lib/router-utils/build-prefetch-segment-data-route.ts`). * Updated the `PrefetchSegmentDataRoute` type to include `routeKeys` for better route matching and added logic for generating these keys (`packages/next/src/server/lib/router-utils/build-prefetch-segment-data-route.ts`). [[1]](diffhunk://#diff-35b900720f7fd8bc8995f5dad9880b2ffafba0638ec6c949efc9ba34b0acc9cbR15) [[2]](diffhunk://#diff-35b900720f7fd8bc8995f5dad9880b2ffafba0638ec6c949efc9ba34b0acc9cbL27-R29) * Modified the build process to utilize `buildInversePrefetchSegmentDataRoute` for dynamic routes with undefined segment paths when `clientSegmentCache` is enabled (`packages/next/src/build/index.ts`). ### Codebase improvements: * Added `originalAppPath` to the `PageInfo` interface to track the original path of app pages and routes, improving route handling logic (`packages/next/src/build/utils.ts`). * Simplified the logic for appending prefetch segment data routes by directly pushing the result of `buildPrefetchSegmentDataRoute` instead of using intermediate variables (`packages/next/src/build/index.ts`). ### Testing and experimental features: * Added comprehensive unit tests for `buildInversePrefetchSegmentDataRoute` to ensure correct behavior and compatibility with existing route utilities (`packages/next/src/server/lib/router-utils/build-prefetch-segment-data-route.test.ts`). * Introduced a new E2E test suite for validating conflicting routes and prefetching behavior under the experimental `clientSegmentCache` feature (`test/e2e/app-dir/segment-cache/conflicting-routes`). * Enabled experimental features like `clientSegmentCache` and `ppr` (partial prerendering) in the test configuration to validate their integration (`test/e2e/app-dir/segment-cache/conflicting-routes/next.config.js`). <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as s moothly 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 # -->
-
vercel-release-bot authored
-
Benjamin Woodruff authored
I thought this was already here, but @lukesandberg pointed out it wasn't. I'm pretty sure we're doing transmutes in a few places that assume this, so we should have it. There's likely no change in behavior: The only sane memory layout for these types is the transparent one, but the annotation guarantees it for our unsafe code.
-
Maria Vanessa Salim authored
### What? Updates the `userAgent` middleware example in the documentation to accurately reflect all possible values of `device.type` and demonstrate proper handling of desktop browsers (undefined case). ### Why? The current example shows a binary mobile/desktop check which doesn't accurately reflect the API's capabilities. The `device.type` property can actually return multiple values ('mobile', 'tablet', 'console', 'smarttv', 'wearable', 'embedded', or undefined), but the example only shows handling of 'mobile', which could mislead developers. ### How? - Updated both TypeScript and JavaScript examples to: 1. Add comprehensive comments documenting all possible `device.type` values 2. Use proper undefined handling with the OR operator for desktop browsers 3. Maintain consistency between TS and JS versions 4. Better align with the documented behavior in the API reference - Ran `pnpm prettier-fix` to ensure proper formatting - Followed the [Docs Contribution Guide](https://nextjs.org/docs/community/contribution-guide) The changes help developers better understand: - The full range of device types they can detect - How desktop browsers return undefined - The proper way to handle device type detection - Consistency with the rest of the API documentation ### Checklist - [x] Read the [Docs Contribution Guide](https://nextjs.org/docs/community/contribution-guide) - [x] Ran `pnpm prettier-fix` to fix formatting issues - [x] Ensured examples are clear and follow documentation best practices - [x] Maintained consistency with existing documentation style - [x] Verified the accuracy of the technical information --------- Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Andrew Clark authored
The prefetch scheduler limits the number of concurrent prefetch requests, to avoid saturating browser's internal network queue. As a starting point, I had previously hardcoded this to 3 — intentionally stingy, to leave room for additional optimizations. In this PR, I allow the most recently hovered link to exceed the default limit. This increased limit only applies to the *most recently* hovered link; if a different link is hovered, the previous one is bumped back down to the default. The principle is that when hovering over a new link, we should have enough bandwidth to start prefetching its data. (In practice, because we don't cancel in-progress requests, it's still possible that we'll fill up the queue, but this makes it less likely.) As part of this change, I changed the implementation of the internal Intent priority level. Intent used to assigned to any link that was ever hovered over; it would never get bumped back down to Default, even on mouseexit. This was intentional at the time, but given this new optimizaiton, it makes more sense to downgrade previously hovered links to free up the bandwidth.
-
Andrew Clark authored
This commit adds an `onInvalidate` callback to `router.prefetch()` so custom `<Link>` implementations can re-prefetch data when it becomes stale. The callback is invoked when the data associated with the prefetch may have been invalidated (e.g. by `revalidatePath` or `revalidateTag`). This is not a live subscription and should not be treated as one. It's a one-time callback per prefetch request that acts as a signal: "If you care about the freshness of this data, now would be a good time to re-prefetch." The supported use case is for advanced clients who opt out of rendering the built-in `<Link>` component (e.g. to customize visibility tracking or polling behavior) but still want to retain proper cache integration. When the callback is fired, the component can trigger a new call to `router.prefetch()` with the same parameters, including a new `onInvalidate` callback to continue the cycle. (For reference, `<Link>` handles this automatically. This API exists to give custom implementations access to the same underlying behavior.) Note that the callback *may* be invoked even if the prefetched data is still cached. This is intentional—prefetching in the app router is a pull-based mechanism, not a push-based one. Rather than subscribing to the lifecycle of specific cache entries, the app occasionally polls the prefetch layer to check for missing or stale data. Calling `router.prefetch()` does not necessarily result in a network request. If the data is already cached, the call is a no-op. This makes polling a practical way to check cache freshness over time without incurring unnecessary requests.
-
- 19 Apr, 2025 2 commits
-
-
vercel-release-bot authored
-
Tobias Koppers authored
### What? Instead of collecting all modifications to the task graph in a log structure (which ends up taking a lot of memory), use a modified and snapshot flag to avoid using more memory than needed. This way we don't store extra memory before a snapshot is requested. Once a snapshot is captured, we store at most twice the memory. We store only the memory of the modified tasks. It works this way: Idle Phase: (before a snapshot is requested) * When a task is modified, we only set the modified flag on that task. Capturing a snapshot want to avoid locking all tasks. So it first switches to the Snapshot Phase. Snapshot Phase: (after a snapshot is captured) * When a task is modified: * If there is already a snapshot, skip * If the task has the modified flag set, clone the task and store the snapshot. * If the task doesn't have the modified flag set, store a None snapshot. To actually capture the snapshot, go over all modified or snapshot tasks (which is stored in a separate map): * If the task has a snapshot (not None) stored, use that. * If the task has only the modified flag set, read the task state and capture a snapshot from that. * There is a race condition here, when the task is modified inbetween. We handle that by having a snapshot flag too. We have all snapshot captured now. To leave Snapshot Phase, we * First unset all modified flags. * Switch to Idle Phase. * Change all stored snapshots to modified.
-
- 18 Apr, 2025 9 commits
-
-
Benjamin Woodruff authored
The notify crate requires handling rescan events with the event queue overflows. Context on this issue in the notify crate: - https://github.com/notify-rs/notify/issues/412 - https://github.com/notify-rs/notify/issues/434 - https://github.com/notify-rs/notify/pull/435 In our case, that means we should invalidate every file we've read in `turbo-tasks-fs`. We should also attempt to re-add filesystem watchers for every path, since some of those paths could've been removed and re-added. Tested this on Linux by lowering the inotify queue to something tiny to trigger frequent rescan events: ``` echo 3 | sudo tee /proc/sys/fs/inotify/max_queued_events rm -rf /tmp/fuzz && RUST_BACKTRACE=1 cargo run -p turbo-tasks-fuzz -- fs-watcher --fs-root /tmp/fuzz --notify-timeout-ms 100 --directory-modifications 0 echo 16384 | sudo tee /proc/sys/fs/inotify/max_queued_events # restore back to default ``` As a sanity check, I also tried running the fuzzer on macos, though it doesn't seem like there's as easy of a way to trigger rescan events on that platform (?).
-
vercel-release-bot authored
-
JJ Kasper authored
Our encoding test in `vercel/vercel` started failing from https://github.com/vercel/next.js/pull/77994 this reverts part of the change there to ensure we always normalize our dynamic route params. Validated in https://github.com/vercel/vercel/pull/13259 <details> <summary>test failure</summary>  </details> x-ref: [slack thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1744481510502349)
-
JJ Kasper authored
This updates our matcher handling for middleware to ensure we check encoded/decoded versions of the pathname since the regex will most often not handle all encoding variations. This matcher change only affects public/static files as pages/API routes doesn't allow mismatching encoding.
-
JJ Kasper authored
This is one of the intial migrations for https://github.com/vercel/next.js/discussions/77740 which starts by adding the `handler` signature for pages API routes. This new `handler` signature will be added for all route types and allows a consistent way to invoke entries. This also aims to align all logic to no longer be special cased between minimal mode, standalone mode, and just normal `next start`. All modes will behave and process requests the same at the entry level after this is done. Once all route types are migrated `next-server`, `web-server`, and `base-server` will no longer be necessary and a minimal matching layer will be provided to process rewrites/dynamic routes to the related entry instead. The changes here we validated against the `vercel/vercel` [test suite here](https://github.com/vercel/vercel/pull/13231) and --------- Co-authored-by:
Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
-
Janka Uryga authored
rip. you served a purpose once, but now you're just getting in the way. this improves typesafety quite a bit, because `BrowserInterface` had a whole bunch of random `any`s everywhere also - removes `evalAsync`. no idea why that was needed, but we're happily using promises in normal eval, so it can be dropped - adds more safety to `chain`
-
Janka Uryga authored
This PR modifies the AMP HTML testing util to avoid loading the validator from the network, which causes random test flakiness. I've also made it use the validator from `next/dist/compiled` to match what we do during builds. This means we can drop `amphtml-validator` from the root package.json.
-
Janka Uryga authored
this fixes an annoying issue where `eslint-plugin-next` causes a bunch of typescript errors after a `pnpm clean`. the reason for this was that it didn't have a `"dev"` script, so `pnpm dev` ignored it, and so it never got built at all.
-
Jiachi Liu authored
-
- 17 Apr, 2025 18 commits
-
-
Donny/강동윤 authored
### What? Use the `ModulePart::export` fragment instead of resolving it as an internal fragment. Additionally, this PR removes the concept of `ModulePart::InternalEvaluation` because it's not required anymore. ### Why? Treating them as internal fragments causes a duplicate module identifier error. ### How? Closes PACK-4367 --------- Co-authored-by:Benjamin Woodruff <benjamin.woodruff@vercel.com>
-
vercel-release-bot authored
-
Vercel Release Bot authored
[diff facebook/react@b04254fd...4a36d3ea](https://github.com/facebook/react/compare/b04254fd...4a36d3ea) <details> <summary>React upstream changes</summary> - https://github.com/facebook/react/pull/32936 - https://github.com/facebook/react/pull/32935 - https://github.com/facebook/react/pull/32932 - https://github.com/facebook/react/pull/32931 - https://github.com/facebook/react/pull/32930 - https://github.com/facebook/react/pull/32929 - https://github.com/facebook/react/pull/32928 - https://github.com/facebook/react/pull/32934 - https://github.com/facebook/react/pull/32933 </details>
-
Will Binns-Smith authored
-
Niklas Mischkulnig authored
1. Add the import in question to the module ident: `[project]/test/e2e/on-request-error/isr (unsupported edge import fs)` 2. Wrap the source creation into a separate turbotask, so that `fs` and `fs/promises` get the same Source cell (instead of two different Sources with the same ident)
-
Will Binns-Smith authored
-
vercel-release-bot authored
-
Vercel Release Bot authored
-
Jiachi Liu authored
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Vercel Release Bot authored
-
Niklas Mischkulnig authored
-
Jiachi Liu authored
Fixes the function signature changed in #78200
-
Jiachi Liu authored
### What Move built-in `global-error` into a new module, separated from `error-boundary`
-
Delba de Oliveira authored
-
Zack Jackson authored
<!-- 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 # --> Fix failing tests for in DropClientPages mode for alternative bundler --------- Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Delba de Oliveira authored
Closes: https://linear.app/vercel/issue/DOC-4549/production-checklist Redirects: https://github.com/vercel/front/pull/44234
-