Skip to content

fix: close the last Float engine gaps — fallback-hoistable suppression and head priority order - #742

Merged
trueadm merged 2 commits into
mainfrom
fix/parity-final-gaps
Aug 12, 2026
Merged

trueadm merged 2 commits into
mainfrom
fix/parity-final-gaps

Conversation

@trueadm

@trueadm trueadm commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes the last two engine gaps from #711's React 19 parity audit and retires the final planned evidence items, leaving only the diagnostics (warning-message) backlog:

  • Transitive fallback-hoistable suppression (Per ReactDOMFloat-test.js:5431, ledger …c4141d81): a <title>/<meta>/<link> authored inside a pending boundary's fallback never reaches the streamed head — including from a completed boundary nested inside that fallback. The fallback is discarded at reveal, but a streamed head line is permanent, so a fallback hoist would outlive its content.
  • Server hoistable prioritization (Per ReactDOMFloat-test.js:9085, ledger …ed14e46d): <meta charSet> now serializes at the front of the head (parsers only honor a charset within the first 1024 bytes), then <meta name="viewport">, then everything else in discovery order — matching Fizz.
  • Evidence flips for the four remaining actionable planned cases: the identifierPrefix root option (linked to the existing useid-determinism conformance suite) and the three external-store compatibility cases (via useSyncExternalStore semantics: one new client-mount 3-arg-form test, plus links to the existing shared/redux conformance suites).

Ledger after this PR: ReactDOMFloat-test.js planned drops 5 → 3 (only the three warning-message families remain, tracked in the diagnostics backlog); whole-ledger planned 1,928 → 1,922.

Why

Both engine fixes are runtime.server.ts-only:

  • Suppression: a module-level fallback depth incremented by ssrTry's pending-arm wrapper and checked in ssrHeadEl. Nested content arms deliberately never reset it — that's the transitive semantics. Balanced by finally; re-zeroed with each render's head buffer for crash hygiene. Fallback markup (including a nested completed boundary's content) still renders; only head hoists are dropped, exactly like React. Float resources and hints from fallbacks stay registered (resources are page-global; React allows fallback preloads).
  • Prioritization: HeadBuffer gains charset/viewport priority buckets routed at registration (runtime values, so dynamic name/charSet route correctly) and folded ahead of everything else. The buckets joined both suspense-replay snapshot/rewind sites (component replay + the done-boundary fallback render). Ownership markers travel with each element, so hydration adoption is position-independent — the full hydration suite is green.

Red-first evidence

  • Suppression: the new conformance test failed pre-fix with nested-primary-meta present in the streamed shell head (the exact upstream-cited observable).
  • Prioritization: the new test was seen red against the fold order deliberately reverted to html + charset + viewport (only that test failed; restored, all green).
  • The agent-ported external-store test was seen red against a deliberately inverted client/server snapshot read in the fixture (failed in both dev and prod projects; restored).

Review round 1 (Bugbot, fixed in 0fa7962)

Valid invariant finding: FALLBACK_HOIST_DEPTH wasn't carried through saveAmbient/restoreAmbient, whose contract is that everything a pass touches is snapshotted so interleaved renders can't clobber each other. The counter is balanced by withPendingArm's finally within every synchronous pass, and passes only interleave at await points — so a non-zero value is not observable at any interleave point today and no behavioral repro exists (which is why this ships without a new test rather than with one that cannot fail). The field now rides the ambient snapshot like HEAD itself, closing the landmine for any future pass that yields mid-arm. Re-validated: ssr-suspense-isolation + SSR/streaming/head suites 350/350, targeted typecheck and format clean.

Validation

  • pnpm format:files (changed files), pnpm typecheck
  • pnpm test — 20,938 passed; 2 failing files, both triaged as not-from-this-diff: doom-browser is nondeterministic under any load (2/7 then 7/7 across two back-to-back isolation runs of the same code) and swr/root passes 10/10 in isolation (contention flake)
  • node scripts/react-parity/check.mjs --validate-only — metadata current (ledger + coverage byte-checked)
  • the full evidence-executing check.mjs could not complete locally: its parity-wide Vitest lane aborts on a Vite "Port … is in use" line polluting the JSON reporter stream — other concurrent agent sessions on this machine hold test ports (verified via lsof/pgrep: live vitest workers from unrelated worktrees). Every NEW evidence test was executed directly instead (all green, dev+prod); CI's parity shards run on isolated runners and are the authoritative gate here
  • targeted: float-evidence-2 (38, dev+prod), float-evidence-3 (28, dev+prod), neighbor sweep (hydration/, streaming-ssr, float-resources, resource-hints, ssr-stream-state-regressions, external-store-shared, useid-determinism) 1,010/1,010

Risk / follow-ups

  • One test asserts head ORDER case-insensitively: Octane serializes the charSet attribute name camelCase where React lowercases — HTML attribute names are ASCII case-insensitive so this is spec-equivalent; flagged here rather than silently pinned. Trivial to normalize later if byte-parity with React's head output ever matters.
  • Late-discovered (post-shell) charset/viewport metas behave like all late head elements: they don't stream (documented divergence; only the sheet family streams, per fix: ship Float sheet resources discovered after the streaming shell #727).
  • After merge: refresh React 19 parity: outstanding gaps and follow-ups after #709 #711 — with these landed, the issue is closeable modulo the diagnostics backlog (recommend spinning that into its own issue).

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches core SSR streaming head assembly and Suspense fallback rendering; mistakes could leak wrong metadata into <head> or change early-byte layout for parsers, though changes are scoped to runtime.server.ts with targeted conformance coverage.

Overview
Closes the last Float engine gaps called out in the React 19 parity audit by changing server head hoisting in runtime.server.ts.

Transitive fallback suppression: While rendering a @try pending arm, FALLBACK_HOIST_DEPTH increments and ssrHeadEl returns without registering <title> / <meta> / <link>. Nested boundaries that finish inside that fallback still count as fallback territory, so their metadata never lands in the streamed head even though body markup can still show.

Priority head ordering: HeadBuffer adds charset and viewport buckets; <meta charSet> and <meta name="viewport"> fold before other hoistables (charset then viewport, then discovery order). Snapshot/rewind paths track those buffers so suspense replays stay consistent.

Evidence and docs: New/extended conformance covers nested-fallback meta suppression and charset/viewport ordering (float-evidence-2 / float-evidence-3), plus a client-mount useSyncExternalStore case. The React conformance ledger flips several cases from planned to covered (Float tests, identifierPrefix, external-store shims); differences-from-react.md and the changeset describe the behaviors.

Reviewed by Cursor Bugbot for commit 4afa283. Bugbot is set up for automated code reviews on this repo. Configure here.

…n and head priority order

Fallback hoistables are now suppressed transitively on the server: a
title/meta/link authored inside a pending boundary's fallback never reaches
the streamed head, including from a completed boundary nested inside that
fallback — the fallback is discarded at reveal, but a streamed head line is
permanent. Float resources and hints from fallbacks stay registered
(page-global; React allows fallback preloads).

Priority hoistables now lead the server head fold: meta charSet first
(parsers only honor a charset within the first 1024 bytes), then
meta name="viewport", then everything else in discovery order — Fizz parity.
The new HeadBuffer buckets join both suspense-replay snapshot/rewind sites.

Also flips the final actionable evidence cases: identifierPrefix root option,
the three external-store compatibility cases, and the two engine-gap cases
above. ReactDOMFloat-test.js planned drops to 3 (warning families only);
whole-ledger planned 1,928 -> 1,922.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Aug 12, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Fallback hoist depth skips ambient snapshot
    • Added FALLBACK_HOIST_DEPTH to the Ambient interface, saveAmbient(), and restoreAmbient() so nested renders correctly preserve and restore the outer fallback depth counter.

Create PR

Or push these changes by commenting:

@cursor push 5c50f35a4e
Preview (5c50f35a4e)
diff --git a/packages/octane/src/runtime.server.ts b/packages/octane/src/runtime.server.ts
--- a/packages/octane/src/runtime.server.ts
+++ b/packages/octane/src/runtime.server.ts
@@ -5499,6 +5499,7 @@
 	asyncScope: string;
 	ssrElement: SsrElementContext | null;
 	nestingWarnings: Set<string> | null | undefined;
+	fallbackHoistDepth: number;
 	vtTrySeq: number;
 	vtHasCandidates: boolean;
 	vtStack: Array<{ candidate: VtSsrCandidate; consumed: boolean }>;
@@ -5526,6 +5527,7 @@
 		asyncScope: ASYNC_SCOPE,
 		ssrElement: CURRENT_SSR_ELEMENT,
 		nestingWarnings: SSR_NESTING_WARNINGS,
+		fallbackHoistDepth: FALLBACK_HOIST_DEPTH,
 		vtTrySeq: VT_SSR_TRY_SEQ,
 		vtHasCandidates: VT_SSR_HAS_CANDIDATES,
 		vtStack: VT_SSR_STACK.map((candidate) => ({ candidate, consumed: candidate.consumed })),
@@ -5554,6 +5556,7 @@
 	ASYNC_SCOPE = a.asyncScope;
 	CURRENT_SSR_ELEMENT = a.ssrElement;
 	SSR_NESTING_WARNINGS = a.nestingWarnings;
+	FALLBACK_HOIST_DEPTH = a.fallbackHoistDepth;
 	VT_SSR_TRY_SEQ = a.vtTrySeq;
 	VT_SSR_HAS_CANDIDATES = a.vtHasCandidates;
 	VT_SSR_STACK.length = 0;

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 4afa283. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
FALLBACK_HOIST_DEPTH is balanced by withPendingArm's finally within every
synchronous pass, so no interleave point can observe a non-zero value today —
but Ambient's contract is that EVERYTHING a pass touches is saved and
restored, and an unsaved global is a landmine for any future pass that yields
mid-arm. (Bugbot review finding.)

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review August 12, 2026 20:39
@trueadm
trueadm merged commit 125c861 into main Aug 12, 2026
46 checks passed
@trueadm
trueadm deleted the fix/parity-final-gaps branch August 12, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant