Skip to content

Stop emitting a redundant route per prefetch segment - #97720

Merged
unstubbable merged 1 commit into
hl/adapter-routing-baselinefrom
hl/adapter-drop-segment-prefetch-routes
Aug 24, 2026
Merged

unstubbable merged 1 commit into
hl/adapter-routing-baselinefrom
hl/adapter-drop-segment-prefetch-routes

Conversation

@unstubbable

@unstubbable unstubbable commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

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:

- /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. 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.

@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: f5d30a6

@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Stats from current PR

🟢 2 improvements

Metric Canary PR Change Trend
Webpack Build Time 25.657s 24.602s 🟢 1.055s (-4%) ▃▆▂▅▅
Webpack Build Time (cached) 24.773s 24.153s 🟢 620ms (-3%) ▃▆▂▄▄
📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 813ms 812ms ✓ █████
Cold (Ready in log) 792ms 796ms ✓ ▃▃█▄▄
Cold (First Request) 1.255s 1.269s ✓ ▃▃█▂▃
Warm (Listen) 812ms 812ms ✓ █████
Warm (Ready in log) 794ms 793ms ✓ ▄▃▇▄▄
Warm (First Request) 1.246s 1.239s ✓ ▁▂▇▁▃
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 812ms 813ms ✓ ▁▁▁▁▁
Cold (Ready in log) 800ms 790ms ✓ ▃▅▂▂▄
Cold (First Request) 3.336s 3.297s ✓ ▂▅▁▄▅
Warm (Listen) 813ms 812ms ✓ ██▁██
Warm (Ready in log) 793ms 796ms ✓ ▄▇▁▃▅
Warm (First Request) 3.352s 3.330s ✓ ▄▇▁▄▆

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 5.646s 5.640s ✓ ▂▃▅▂▁
Cached Build 2.937s 2.874s ✓ ▁▃▆▂▂
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 25.657s 24.602s 🟢 1.055s (-4%) ▃▆▂▅▅
Cached Build 24.773s 24.153s 🟢 620ms (-3%) ▃▆▂▄▄
node_modules Size 552 MB 552 MB ✓ █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
0-jvh6r4ygeg2.js gzip 65.5 kB N/A -
017_4moyv5m34.js gzip 117 B 117 B ✓
05jocc85-b73_.js gzip 341 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB ✓
0e5lgz-xcf6ln.js gzip 273 B 273 B ✓
0enhddgqs2dl-.js gzip 265 B 265 B ✓
0h34mejwa_7pd.js gzip 354 B 354 B ✓
0w853zxni3ro0.js gzip 1.36 kB N/A -
13lq2aw3_0bgw.js gzip 3.52 kB N/A -
1elt1qium-r2m.css gzip 115 B 115 B ✓
1m5vdnlf0deiv.js gzip 411 B 411 B ✓
1nigpy_mr0xvj.js gzip 339 B N/A -
1p0l8mn2wz5f2.js gzip 1.97 kB N/A -
1s-3t9k2_uhom.js gzip 117 B N/A -
1sqoyy39jpgkq.js gzip 121 B 121 B ✓
1tf1phijqlx9j.js gzip 220 B 220 B ✓
2b05_424u1zq-.js gzip 120 B N/A -
2ca40xittx95r.js gzip 8.75 kB N/A -
2hfnapus1iuka.js gzip 71.5 kB N/A -
2hgz42b8sldyc.js gzip 5.85 kB N/A -
2kci0vnt-49o-.js gzip 113 B 113 B ✓
2sxgl_rcrrn_p.js gzip 399 B N/A -
2u_p__ndkooh-.js gzip 5.66 kB N/A -
2vst0p6zpfrr_.js gzip 7.53 kB N/A -
2vt62i17bhbdu.js gzip 2.35 kB N/A -
342di-crrg9kq.js gzip 119 B N/A -
36bhyc0i1hpg3.js gzip 46.7 kB N/A -
36hfc2_979aw2.js gzip 119 B N/A -
38wfp6jjrrdfm.js gzip 131 B 131 B ✓
3dl1ilk37-30g.js gzip 117 B N/A -
3h0us7yy7bd_o.js gzip 13.1 kB N/A -
3kvxagoobts7h.js gzip 117 B N/A -
3p99hd9vwe6ae.js gzip 13 kB N/A -
3r0475panhk6m.js gzip 123 B N/A -
3s0i-weykgzrt.js gzip 125 B N/A -
3wijk2ywqgsv9.js gzip 2.52 kB N/A -
41u5s3oe2-erp.js gzip 2.29 kB N/A -
42ngmkoqu05nv.js gzip 155 B N/A -
turbopack-0d..9ejy.js gzip 3.74 kB 3.74 kB ✓
02zc7sqlpqxn3.js gzip N/A 119 B -
0at_009gd70pg.js gzip N/A 153 B -
0e28eh3gbwmp0.js gzip N/A 3.51 kB -
0jwho9fkrb_t3.js gzip N/A 2.29 kB -
0longconn5mlm.js gzip N/A 123 B -
0p4l3ozbez2cz.js gzip N/A 2.35 kB -
0sbh_15ejop4o.js gzip N/A 13 kB -
0skdm-9rpid8g.js gzip N/A 117 B -
0wv-h56sz83wn.js gzip N/A 120 B -
137xup2t69ovc.js gzip N/A 1.97 kB -
1fk10s3m1oecx.js gzip N/A 400 B -
20qhkyyj2_tla.js gzip N/A 116 B -
25lb_468wpv8t.js gzip N/A 117 B -
25t26px0lbw0i.js gzip N/A 71.5 kB -
2imyufe18bsb7.js gzip N/A 1.36 kB -
2kfge3wavhjzk.js gzip N/A 65.5 kB -
2mr-6hunyw7uo.js gzip N/A 7.53 kB -
2p4n3-8-xixh_.js gzip N/A 341 B -
2vqdfieehz5do.js gzip N/A 8.75 kB -
2xn85ykzw2v1e.js gzip N/A 13.1 kB -
33gdcu1dj0nl9.js gzip N/A 46.7 kB -
34knadd6wu9qg.js gzip N/A 119 B -
37-g1kp39exux.js gzip N/A 5.85 kB -
39jq2b6t6z6up.js gzip N/A 339 B -
3a9a9tvkag_-j.js gzip N/A 2.52 kB -
3hk-fj9wj-l1s.js gzip N/A 5.66 kB -
3t121tj-h0kbm.js gzip N/A 125 B -
Total 299 kB 299 kB ✅ -2 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 1.02 kB 1.02 kB ✓
Total 1.02 kB 1.02 kB ⚠️ +1 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 846 B 845 B ✓
Total 846 B 845 B ✅ -1 B
Build Cache
Canary PR Change
00000001.sst gzip 12 MB 13 MB 🔴 +983 kB (+8%)
00000002.sst gzip 14 MB 15.6 MB 🔴 +1.55 MB (+11%)
00000003.sst gzip 15.5 MB 12.3 MB 🟢 3.13 MB (-20%)
00000004.sst gzip 13.5 MB 14.1 MB 🔴 +625 kB (+5%)
00000005.sst gzip 10.2 MB 10.2 MB 🟢 24.7 kB (0%)
00000006.sst gzip 2.79 MB 2.79 MB ✓
00000007.sst gzip 59 B 59 B ✓
00000008.meta gzip 89 B 298 kB 🔴 +298 kB (+334439%)
00000009.meta gzip 298 kB 89 B 🟢 298 kB (-100%)
00000010.meta gzip 298 kB 298 kB ✓
00000011.meta gzip 298 kB 298 kB ✓
00000012.sst gzip 53.8 kB 53 kB 🟢 792 B (-1%)
00000013.sst gzip 1.77 MB 1.82 MB 🔴 +53.1 kB (+3%)
00000014.sst gzip 59 B 59 B ✓
00000015.meta gzip 116 B 116 B ✓
00000016.meta gzip 327 kB 328 kB ✓
00000017.meta gzip 405 kB 406 kB ✓
00000018.sst gzip 54.6 kB 54 kB 🟢 606 B (-1%)
00000019.sst gzip 1.38 MB 1.38 MB ✓
00000020.sst gzip 59 B 59 B ✓
00000021.meta gzip 116 B 116 B ✓
00000022.meta gzip 327 kB 328 kB ✓
00000023.meta gzip 372 kB 372 kB ✓
00000024.sst gzip 54.8 kB 54.1 kB 🟢 671 B (-1%)
00000025.sst gzip 1.38 MB 1.38 MB ✓
00000026.sst gzip 59 B 59 B ✓
00000027.meta gzip 116 B 116 B ✓
00000028.meta gzip 327 kB 328 kB ✓
00000029.meta gzip 372 kB 372 kB ✓
00000030.sst gzip 54 kB 53.1 kB 🟢 889 B (-2%)
00000031.sst gzip 1.38 MB 1.38 MB ✓
00000032.sst gzip 59 B 59 B ✓
00000033.meta gzip 116 B 116 B ✓
00000034.meta gzip 327 kB 328 kB ✓
00000035.meta gzip 372 kB 372 kB ✓
00000036.sst gzip 54.6 kB 54 kB 🟢 563 B (-1%)
00000037.sst gzip 1.38 MB 1.38 MB ✓
00000038.sst gzip 59 B 59 B ✓
00000039.meta gzip 116 B 116 B ✓
00000040.meta gzip 327 kB 328 kB ✓
00000041.meta gzip 372 kB 372 kB ✓
CURRENT gzip 93 B 92 B 🟢 1 B (-1%)
LOG gzip 681 B 666 B 🟢 15 B (-2%)
Total 80 MB 80 MB ⚠️ +46.1 kB

📦 Webpack

Client

Main Bundles
Canary PR Change
3322-HASH.js gzip 65.6 kB N/A -
4191.HASH.js gzip 169 B N/A -
9784-HASH.js gzip 5.57 kB N/A -
b1ad9f4c-HASH.js gzip 63.5 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB ✓
main-app-HASH.js gzip 253 B 254 B ✓
main-HASH.js gzip 39.8 kB 39.7 kB ✓
webpack-HASH.js gzip 1.68 kB 1.68 kB ✓
3577.HASH.js gzip N/A 168 B -
578-HASH.js gzip N/A 65.8 kB -
8590-HASH.js gzip N/A 5.53 kB -
a8984546-HASH.js gzip N/A 63.5 kB -
Total 236 kB 236 kB ⚠️ +100 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB ✓
Total 39.4 kB 39.4 kB ✓
Pages
Canary PR Change
_app-HASH.js gzip 194 B 193 B ✓
_error-HASH.js gzip 181 B 182 B ✓
css-HASH.js gzip 334 B 331 B ✓
dynamic-HASH.js gzip 1.81 kB 1.81 kB ✓
edge-ssr-HASH.js gzip 255 B 253 B ✓
head-HASH.js gzip 349 B 351 B ✓
hooks-HASH.js gzip 382 B 384 B ✓
image-HASH.js gzip 5.02 kB 5.01 kB ✓
index-HASH.js gzip 260 B 259 B ✓
link-HASH.js gzip 2.48 kB 2.48 kB ✓
routerDirect..HASH.js gzip 317 B 318 B ✓
script-HASH.js gzip 384 B 386 B ✓
withRouter-HASH.js gzip 316 B 315 B ✓
1afbb74e6ecf..834.css gzip 106 B 106 B ✓
Total 12.4 kB 12.4 kB ✓

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 128 kB 128 kB ✓
page.js gzip 292 kB 292 kB ✓
Total 420 kB 420 kB ✅ -366 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 600 B 601 B ✓
middleware-r..fest.js gzip 156 B 156 B ✓
middleware.js gzip 45.6 kB 45.2 kB ✓
edge-runtime..pack.js gzip 842 B 842 B ✓
Total 47.2 kB 46.8 kB ✅ -406 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 698 B 698 B ✓
Total 698 B 698 B ✓
Build Cache
Canary PR Change
0.pack gzip 4.79 MB 4.78 MB 🟢 8.7 kB (0%)
index.pack gzip 124 kB 124 kB ✓
index.pack.old gzip 124 kB 123 kB ✓
Total 5.04 MB 5.03 MB ✅ -10 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 373 kB 373 kB ✓
app-page-exp..prod.js gzip 206 kB 206 kB ✓
app-page-tur...dev.js gzip 373 kB 373 kB ✓
app-page-tur..prod.js gzip 206 kB 206 kB ✓
app-page-tur...dev.js gzip 369 kB 369 kB ✓
app-page-tur..prod.js gzip 203 kB 203 kB ✓
app-page.run...dev.js gzip 370 kB 370 kB ✓
app-page.run..prod.js gzip 203 kB 203 kB ✓
app-route-ex...dev.js gzip 82.5 kB 82.5 kB ✓
app-route-ex..prod.js gzip 55.6 kB 55.6 kB ✓
app-route-tu...dev.js gzip 82.5 kB 82.5 kB ✓
app-route-tu..prod.js gzip 55.6 kB 55.6 kB ✓
app-route-tu...dev.js gzip 82.1 kB 82.1 kB ✓
app-route-tu..prod.js gzip 55.4 kB 55.4 kB ✓
app-route.ru...dev.js gzip 82.1 kB 82.1 kB ✓
app-route.ru..prod.js gzip 55.4 kB 55.4 kB ✓
dev-validati...dev.js gzip 134 kB 134 kB ✓
dev-validati...dev.js gzip 134 kB 134 kB ✓
dev-validati...dev.js gzip 132 kB 132 kB ✓
dev-validati...dev.js gzip 132 kB 132 kB ✓
dist_client_...dev.js gzip 324 B 324 B ✓
dist_client_...dev.js gzip 326 B 326 B ✓
dist_client_...dev.js gzip 318 B 318 B ✓
dist_client_...dev.js gzip 317 B 317 B ✓
pages-api-tu...dev.js gzip 46.2 kB 46.2 kB ✓
pages-api-tu..prod.js gzip 34.3 kB 34.3 kB ✓
pages-api.ru...dev.js gzip 46.2 kB 46.2 kB ✓
pages-api.ru..prod.js gzip 34.2 kB 34.2 kB ✓
pages-turbo....dev.js gzip 54.6 kB 54.6 kB ✓
pages-turbo...prod.js gzip 39.6 kB 39.6 kB ✓
pages.runtim...dev.js gzip 54.6 kB 54.6 kB ✓
pages.runtim..prod.js gzip 39.6 kB 39.6 kB ✓
server.runti..prod.js gzip 65.8 kB 65.8 kB ✓
use-cache-pr...dev.js gzip 72.5 kB 72.5 kB ✓
use-cache-pr...dev.js gzip 72.5 kB 72.5 kB ✓
use-cache-pr...dev.js gzip 70.7 kB 70.7 kB ✓
use-cache-pr...dev.js gzip 70.7 kB 70.7 kB ✓
Total 4.09 MB 4.09 MB ⚠️ +13 B
📝 Changed Files (1 file)

Files with changes:

  • server.runtime.prod.js
View diffs
server.runtime.prod.js

Diff too large to display

📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/f5d30a639e60151a38e54fd66b7e72a2c25fdd40/next

Commit: f5d30a6

@unstubbable
unstubbable force-pushed the hl/adapter-drop-segment-prefetch-routes branch from c5b9ed3 to 56465e9 Compare August 21, 2026 23:22
@unstubbable
unstubbable force-pushed the hl/adapter-drop-segment-prefetch-routes branch from 56465e9 to 7d61fb8 Compare August 21, 2026 23:52
@unstubbable
unstubbable marked this pull request as ready for review August 22, 2026 01:27
dianatofficial

This comment was marked as low quality.

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
unstubbable force-pushed the hl/adapter-drop-segment-prefetch-routes branch from 7d61fb8 to f5d30a6 Compare August 22, 2026 13:57
@unstubbable
unstubbable merged commit 7678e6e into canary Aug 24, 2026
132 checks passed
@unstubbable
unstubbable deleted the hl/adapter-drop-segment-prefetch-routes branch August 24, 2026 08:41
@github-actions github-actions Bot added the locked label Sep 7, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants