Skip to content

Fix prefetch inlining build failure with dynamic routes#90899

Merged
acdlite merged 1 commit intovercel:canaryfrom
acdlite:fix/prefetch-inlining-dynamic-build
Mar 5, 2026
Merged

Fix prefetch inlining build failure with dynamic routes#90899
acdlite merged 1 commit intovercel:canaryfrom
acdlite:fix/prefetch-inlining-dynamic-build

Conversation

@acdlite
Copy link
Contributor

@acdlite acdlite commented Mar 4, 2026

When prefetchInlining is enabled, the segment data collection returns a special key for the inlined response. Previously this key was /_inlined, but the build validation code in packages/next/src/build/index.ts expects segment paths to contain __PAGE__. This caused builds to fail with "Invariant: missing PAGE segmentPath" for any dynamic route using prefetchInlining.

Fix by using the same PAGE_SEGMENT_KEY (__PAGE__) constant for the inlined segment response key, matching what the build code already expects. This is consistent since the inlined response serves the same role as the per-page segment data — it just bundles all segments together.

Closes #90850

Co-authored-by: Ben Salmon ben.salmon@daylightgroup.nz

@acdlite acdlite marked this pull request as ready for review March 4, 2026 23:17
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Mar 4, 2026

Failing test suites

Commit: 3e73cd1 | About building and testing Next.js

pnpm test-dev-turbo test/development/app-dir/hmr-intercept-routes/hmr-intercept-routes.test.ts (turbopack) (job)

  • hmr-intercept-routes > should update intercept routes via HMR (DD)
Expand output

● hmr-intercept-routes › should update intercept routes via HMR

page.waitForSelector: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('#default-intercept') to be visible

  519 |
  520 |     return this.startChain(async () => {
> 521 |       const el = await page.waitForSelector(selector, {
      |                             ^
  522 |         timeout,
  523 |         state,
  524 |       })

  at waitForSelector (lib/browsers/playwright.ts:521:29)
  at Playwright._chain (lib/browsers/playwright.ts:651:23)
  at Playwright._chain [as startChain] (lib/browsers/playwright.ts:632:17)
  at Playwright.startChain [as waitForElementByCss] (lib/browsers/playwright.ts:520:17)
  at Object.waitForElementByCss (development/app-dir/hmr-intercept-routes/hmr-intercept-routes.test.ts:38:21)

pnpm test-dev-turbo test/development/dev-indicator/dev-rendering-indicator.test.ts (turbopack) (job)

  • Dev Rendering Indicator > Shows build indicator when page is built from modifying (DD)
Expand output

● Dev Rendering Indicator › Shows build indicator when page is built from modifying

expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Object {
-   "showedRenderingIndicator": true,
+   "showedRenderingIndicator": false,
  }

  42 |
  43 |     const showedRenderingIndicator = await browser.eval('window.showedBuilder')
> 44 |     expect({ showedRenderingIndicator }).toEqual({
     |                                          ^
  45 |       showedRenderingIndicator: true,
  46 |     })
  47 |   })

  at Object.toEqual (development/dev-indicator/dev-rendering-indicator.test.ts:44:42)

@bensalmon-daylight
Copy link
Contributor

Looks good, my email is actually ben.salmon@daylightgroup.nz though.

@acdlite
Copy link
Contributor Author

acdlite commented Mar 5, 2026

Ahaha maybe Claude hallucinated the email

When prefetchInlining is enabled, the segment data collection
returns a special key for the inlined response. Previously this
key was `/_inlined`, but the build validation code in
`packages/next/src/build/index.ts` expects segment paths to
contain `__PAGE__`. This caused builds to fail with
"Invariant: missing __PAGE__ segmentPath" for any dynamic route
using prefetchInlining.

Fix by using the same `PAGE_SEGMENT_KEY` (`__PAGE__`) constant
for the inlined segment response key, matching what the build
code already expects. This is consistent since the inlined
response serves the same role as the per-page segment data —
it just bundles all segments together.

Co-authored-by: Ben Salmon <ben.salmon@daylightgroup.nz>
@acdlite acdlite force-pushed the fix/prefetch-inlining-dynamic-build branch from 8b399af to 3e73cd1 Compare March 5, 2026 03:42
@acdlite acdlite merged commit 747d3dc into vercel:canary Mar 5, 2026
271 of 276 checks passed
sokra pushed a commit that referenced this pull request Mar 6, 2026
When prefetchInlining is enabled, the segment data collection returns a
special key for the inlined response. Previously this key was
`/_inlined`, but the build validation code in
`packages/next/src/build/index.ts` expects segment paths to contain
`__PAGE__`. This caused builds to fail with "Invariant: missing __PAGE__
segmentPath" for any dynamic route using prefetchInlining.

Fix by using the same `PAGE_SEGMENT_KEY` (`__PAGE__`) constant for the
inlined segment response key, matching what the build code already
expects. This is consistent since the inlined response serves the same
role as the per-page segment data — it just bundles all segments
together.

Closes #90850

Co-authored-by: Ben Salmon <ben.salmon@daylightgroup.nz>

Co-authored-by: Ben Salmon <ben.salmon@daylightgroup.nz>
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.

3 participants