Give route-shaped dev server strings distinct types - #96786
Closed
gaearon wants to merge 1 commit into
Closed
Conversation
Contributor
Stats from current PR🔴 1 regression
📊 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 (2 files)Files with changes:
View diffspages-api-tu..ntime.dev.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display 📎 Tarball URLCommit: 7a6376f |
Contributor
Tests PassedCommit: 7a6376f |
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 03:18
5de90dc to
bfe6b9b
Compare
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 03:23
bfe6b9b to
dc94622
Compare
gaearon
marked this pull request as ready for review
August 6, 2026 03:25
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 03:56
dc94622 to
3c8737a
Compare
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
2 times, most recently
from
August 6, 2026 08:03
41d3220 to
1219bb2
Compare
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 08:33
1219bb2 to
1175bf7
Compare
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 09:00
1175bf7 to
80cc099
Compare
Turbopack's entrypoints keep routes in maps keyed by string namespaces that
look alike but rarely equal each other: the routes map is keyed by route
pathname ("/blog"), and the app entrypoints map by entry name
("/blog/page"). Mixing them up compiles fine and silently never matches —
which is how the dev server came to announce every app route as added on
every update (fixed at the bottom of this stack).
Brand the two namespaces (TurbopackRouteKey, AppEntryName) the way EntryKey
already guards entry keys: a plain string can't be used where a branded key
is expected, and the brands can't be used in each other's place. Reverting
the announcement fix no longer compiles:
error TS2345: Argument of type 'TurbopackRouteKey' is not assignable to
parameter of type 'AppEntryName'.
error TS2345: Argument of type 'string' is not assignable to parameter
of type 'TurbopackRouteKey'.
Strings enter the namespaces at the NAPI boundary (route construction in
swc/index.ts) and leave through message payloads, where the brands widen
back to plain strings. normalizedPageToTurbopackStructureRoute returns an
entry name — per its own comment it maps a normalized page path back to
Turbopack's entry key — and is typed accordingly.
No runtime change.
gaearon
force-pushed
the
gaearon-dev-route-string-types
branch
from
August 6, 2026 12:46
80cc099 to
7a6376f
Compare
Contributor
Author
|
May revisit this in the future, for now don't want to spend more time on it |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #96783.
Turbopack's entrypoints keep routes in maps keyed by string namespaces that look alike but rarely equal each other: the routes map is keyed by route pathname (
/blog), while the app entrypoints map is keyed by entry name (/blog/page). Mixing them up compiles fine and silently never matches — which is how the dev server came to announce every app route as added on every update (fixed at the bottom of this stack, #96250).This brands the two namespaces the way
EntryKeyalready guards entry keys:TurbopackRouteKey— keys ofRawEntrypoints.routesAppEntryName—originalName/ keys ofAppEntrypointsA plain string can't be used where a branded key is expected, and the brands can't be used in each other's place. Reverting #96250's fix no longer compiles:
Strings enter the namespaces at the NAPI boundary (route construction in
swc/index.ts) and leave through message payloads, where the brands widen back to plain strings.normalizedPageToTurbopackStructureRoutereturns an entry name — per its own comment it maps a normalized page path back to Turbopack's entry key — and is typed accordingly. Pages Router maps are left as plain strings: there the route pathname and the page name are genuinely the same string.No runtime change;
route-change-refetchpasses 10/10 as a sanity check.