close
Skip to content

prefetchInlining: fix build crash on notFound() pages#92806

Merged
acdlite merged 2 commits intovercel:canaryfrom
acdlite:prefetch-inlining-not-found-fix
Apr 15, 2026
Merged

prefetchInlining: fix build crash on notFound() pages#92806
acdlite merged 2 commits intovercel:canaryfrom
acdlite:prefetch-inlining-not-found-fix

Conversation

@acdlite
Copy link
Copy Markdown
Contributor

@acdlite acdlite commented Apr 15, 2026

When traversing the route tree in collectPrefetchHints, we use keys from the FlightRouterState to look up corresponding entries in the seed data object. Usually these two structures agree, but there are subtle cases like notFound() where the router state contains keys that don't exist in the seed data. TypeScript doesn't catch this because the in operator narrows the key to string, which is assignable to the seed data object's index signature — but the lookup returns undefined rather than null.

Eventually the plan is to converge these into a single data structure so this kind of mismatch can't happen structurally. For now, coalesce undefined to null with ?? null, matching the pattern already used in ppr-navigations.ts and segment-cache/cache.ts on the client.

Test plan

  • Added regression test: page with notFound() + generateStaticParams under prefetchInlining
  • Verified the build crashes without the fix and passes with it
  • All existing prefetch-inlining tests continue to pass

@acdlite acdlite marked this pull request as ready for review April 15, 2026 00:27
When traversing the route tree in collectPrefetchHints, we use keys from
the FlightRouterState to look up corresponding entries in the seed data
object. Usually these two structures agree, but there are subtle cases
like notFound() where the router state contains keys that don't exist in
the seed data. TypeScript doesn't catch this because the `in` operator
narrows the key to `string`, which is assignable to the seed data
object's index signature — but the lookup returns `undefined` rather
than `null`.

Eventually the plan is to converge these into a single data structure so
this kind of mismatch can't happen structurally. For now, coalesce
undefined to null with `?? null`, matching the pattern already used in
ppr-navigations.ts and segment-cache/cache.ts on the client.
@acdlite acdlite force-pushed the prefetch-inlining-not-found-fix branch from f87c20d to e8e1936 Compare April 15, 2026 00:30
@acdlite acdlite merged commit f765823 into vercel:canary Apr 15, 2026
173 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants