Repository navigation
Stop emitting a redundant route per prefetch segment - #97720
Merged
unstubbable merged 1 commit intoAug 24, 2026
Merged
unstubbable merged 1 commit into
unstubbable merged 1 commit into
Conversation
Contributor
Tests PassedCommit: f5d30a6 |
Contributor
Stats from current PR🟢 2 improvements
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (1 file)Files with changes:
View diffsserver.runtime.prod.jsDiff too large to display 📎 Tarball URLCommit: f5d30a6 |
unstubbable
force-pushed
the
hl/adapter-drop-segment-prefetch-routes
branch
from
August 21, 2026 23:22
c5b9ed3 to
56465e9
Compare
unstubbable
force-pushed
the
hl/adapter-drop-segment-prefetch-routes
branch
from
August 21, 2026 23:52
56465e9 to
7d61fb8
Compare
unstubbable
marked this pull request as ready for review
August 22, 2026 01:27
For a dynamic app page that has a fallback shell, say `/[lang]/[slug]` with a shell for the root param value `de`, the build emits three routes to an adapter. Simplified, with the request pattern on the left and the artifact it resolves to on the right: ```diff - /de/<slug>.segments/$d$lang/$d$slug<seg> -> /de/[slug].segments/$d$lang/$d$slug<seg> /de/<slug><.rsc|.segments/*.segment.rsc> -> /de/[slug]<matched suffix> /de/<slug> -> /de/[slug] ``` This change removes the first one. The second already covers it: its suffix group accepts `.segments/<path>.segment.rsc` as well as `.rsc`, and it copies the matched suffix into the destination, so a per-segment request resolves to the same artifact either way. That second route is also the only one that ever answered `_tree` and `_full` requests, because a per-segment route pins one literal segment path in its regex. A `_tree` prefetch for `/de/<slug>` resolves to `/de/[slug].segments/_tree.segment.rsc`, which the per-segment route cannot produce. So this removes a duplicate, not a mechanism. Only fallback shells emit per-segment routes, because their artifacts sit under an unresolved param and need a rewrite to reach. Segment artifacts for a concrete prerendered path need none, since a request for that path matches them directly. Apps with many shells therefore lose close to a third of their routes. We measured an in-progress feature branch of the v0 chat app, which enumerates precomputed flag, locale and device permutations in `generateStaticParams` for a top-level dynamic segment and so multiplies every route below it. Building that branch before and after the change removes 32% of its routes, adds none, and changes nothing else once the build ID is normalized. This also adds `experimental.collapseAdapterRoutes`. It defaults to `true`, and it controls this collapse together with the ones that follow in this stack. A build that sets it to `false` emits the same route table as a build without any change in this stack. `prefetchSegmentDataRoutes` stays in `routes-manifest.json`, which the non-adapter build path still reads to derive the same routes.
unstubbable
force-pushed
the
hl/adapter-drop-segment-prefetch-routes
branch
from
August 22, 2026 13:57
7d61fb8 to
f5d30a6
Compare
mischnic
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a dynamic app page that has a fallback shell, say
/[lang]/[slug]with a shell for the root param valuede, the build emits three routes to an adapter. Simplified, with the request pattern on the left and the artifact it resolves to on the right:- /de/<slug>.segments/$d$lang/$d$slug<seg> -> /de/[slug].segments/$d$lang/$d$slug<seg> /de/<slug><.rsc|.segments/*.segment.rsc> -> /de/[slug]<matched suffix> /de/<slug> -> /de/[slug]This change removes the first one. The second already covers it: its suffix group accepts
.segments/<path>.segment.rscas well as.rsc, and it copies the matched suffix into the destination, so a per-segment request resolves to the same artifact either way.That second route is also the only one that ever answered
_treeand_fullrequests, because a per-segment route pins one literal segment path in its regex. A_treeprefetch for/de/<slug>resolves to/de/[slug].segments/_tree.segment.rsc, which the per-segment route cannot produce. So this removes a duplicate, not a mechanism.Only fallback shells emit per-segment routes, because their artifacts sit under an unresolved param and need a rewrite to reach. Segment artifacts for a concrete prerendered path need none, since a request for that path matches them directly. Apps with many shells therefore lose close to a third of their routes. We measured an in-progress feature branch of the v0 chat app, which enumerates precomputed flag, locale and device permutations in
generateStaticParamsfor a top-level dynamic segment and so multiplies every route below it. Building that branch before and after the change removes 32% of its routes, adds none, and changes nothing else once the build ID is normalized.This also adds
experimental.collapseAdapterRoutes. It defaults totrue, and it controls this collapse together with the ones that follow in this stack. A build that sets it tofalseemits the same route table as a build without any change in this stack.prefetchSegmentDataRoutesstays inroutes-manifest.json. A build that does not use the adapter reads the field from that manifest and derives the same routes from it. This change therefore leaves that path alone.Verified upstack with a full deploy test run.