Skip to content

fix(next/client): add prerender opt-out to PrefetchCrossZoneLinks#52

Open
runewolf7 wants to merge 1 commit intomainfrom
runewolf/fix-prerender-cross-zone-crash
Open

fix(next/client): add prerender opt-out to PrefetchCrossZoneLinks#52
runewolf7 wants to merge 1 commit intomainfrom
runewolf/fix-prerender-cross-zone-crash

Conversation

@runewolf7
Copy link
Copy Markdown

@runewolf7 runewolf7 commented May 4, 2026

Why

Chrome 147 crashes the browser process (EXC_BREAKPOINT (SIGTRAP) in CrBrowserMain) when activating a prerendered cross-deployment same-origin navigation triggered by the speculation-rules prerender: block this component emits. The crash reproduces on vercel.com cross-zone navigation and disappears when Prerender2 is disabled in chrome://flags or when the prerender: block is dropped from the emitted JSON. prefetch: is unimplicated.

This is a temporary platform-side escape hatch until the underlying Chromium issue is fixed. We're shipping it as a pnpm patch in vercel/front today (vercel/front#69103) by deleting the prerender: block from the installed dist/, and want a sanctioned way for any other consumer to do the same without patching.

What

Adds a prerender?: boolean prop to <PrefetchCrossZoneLinks />, default true — so default behavior is unchanged.

When false, the emitted <script type="speculationrules"> JSON contains only the prefetch: rules and omits the prerender: block entirely. Cross-zone prefetch (hover + visibility) is unaffected.

<PrefetchCrossZoneLinks prerender={false} />

Source-equivalent diff (full diff for context):

+  prerender?: boolean;
 }

 export function PrefetchCrossZoneLinks({
   prerenderEagerness = 'conservative',
+  prerender = true,
 }: PrefetchCrossZoneLinksProps): JSX.Element | null {
   ...
   const speculationRules = {
     prefetch: [ ... ],
-    prerender: [{ eagerness: prerenderEagerness, where: PREFETCH_ON_HOVER_PREDICATES }],
+    ...(prerender ? { prerender: [{ eagerness: prerenderEagerness, where: PREFETCH_ON_HOVER_PREDICATES }] } : {}),
   };

Purely additive; no behavior change for callers that don't pass the prop.

Versioning

Minor (@vercel/microfrontends) — new public prop, default keeps prior behavior.

Follow-ups

  • Once the Chromium prerender activation crash is fixed and rolled out, this prop can be deprecated.
  • Earlier revisions of this PR also tightened the default where: predicate for the prerender: rule to require [data-prefetch]. That change was dropped because it didn't actually prevent the crash in practice — any prerender: rule emitted at all reproduces it on Chrome 147. The opt-out is the only fix that works.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nextjs-app-docs Ready Ready Preview, Comment May 4, 2026 9:37pm
nextjs-app-marketing Ready Ready Preview, Comment May 4, 2026 9:37pm
nextjs-pages-blog Ready Ready Preview, Comment May 4, 2026 9:37pm
nextjs-pages-dashboard Ready Ready Preview, Comment May 4, 2026 9:37pm
react-router-docs Ready Ready Preview, Comment May 4, 2026 9:37pm
react-router-vite-base-path Ready Ready Preview, Comment May 4, 2026 9:37pm
react-router-web Ready Ready Preview, Comment May 4, 2026 9:37pm
single-spa-root Ready Ready Preview, Comment May 4, 2026 9:37pm
single-spa-shared Ready Ready Preview, Comment May 4, 2026 9:37pm
single-spa-web Ready Ready Preview, Comment May 4, 2026 9:37pm
sveltekit-docs Ready Ready Preview, Comment May 4, 2026 9:37pm
sveltekit-web Ready Ready Preview, Comment May 4, 2026 9:37pm

Request Review

Adds a `prerender?: boolean` prop (default `true`) to
`<PrefetchCrossZoneLinks />`. When `false`, the component emits only
the `prefetch:` rules and omits the `prerender:` block from the
`<script type="speculationrules">` JSON. Cross-zone prefetch is
unchanged.

Escape hatch for consumers seeing Chromium prerender-activation
crashes on cross-deployment same-origin navigations (Chrome 147+).
Default behavior unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@runewolf7 runewolf7 force-pushed the runewolf/fix-prerender-cross-zone-crash branch from 8da2cc3 to ccb3465 Compare May 4, 2026 21:36
@runewolf7 runewolf7 changed the title fix(next/client): tighten PrefetchCrossZoneLinks prerender selector and add prerender opt-out fix(next/client): add prerender opt-out to PrefetchCrossZoneLinks May 4, 2026
@runewolf7
Copy link
Copy Markdown
Author

Holding on merging until we see if Chrome 148 lands soon:
https://vercel.slack.com/archives/C0B1DHDQ3S7

This PR may not be needed at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants