Repository navigation
fix: ship Float sheet resources discovered after the streaming shell - #727
Merged
Merged
Conversation
Streaming SSR dropped stylesheet-link and style Float resources whose registration only ran on a post-shell pass (a nested pending boundary's sheet, or an href computed from a use() resolution): only the shell pass's head ever flushed, so late content revealed unstyled until hydration re-inserted the sheet, and no-JS consumers never got the CSS. HeadBuffer.sheets now keeps per-resource entries (href -> precedence + tag; the fold derives groups byte-identically), each wave diffs them against what is already on the wire, and new tags ship with the wave chunk as real markup in a hidden data-oct-fr carrier ahead of the segment reveals. The inline $OCTRH runtime hoists them into document.head under the client's precedence grouping, handing tags to the live client runtime (window.$OCTFR, installed once client Float state exists) so one authority keeps dedupe and group order through mid-stream hydration. A still-pending child boundary's sheet rides its parent's reveal wave, matching React's partial-boundary hoisting. Co-Authored-By: Claude Fable 5 <[email protected]>
trueadm
marked this pull request as ready for review
August 12, 2026 14:33
This was referenced Aug 12, 2026
trueadm
added a commit
that referenced
this pull request
Aug 12, 2026
PR #727 made streaming SSR ship Float stylesheet resources discovered after the shell with their boundary's reveal wave, closing the gap #725 had deferred three ReactDOMFloat-test.js ledger cases against. Flip those cases (:1923 …7b6da8a5, :2041 …8d52f5f3, :2350 …745930fa) to covered with evidence into the 'streamed late boundaries' describe, add one adapted test for the :2350 inline-flush shape (inner boundary resolves first; its complete content and sheet ride the parent's reveal wave exactly once), and regenerate the coverage report. ReactDOMFloat planned drops 8 -> 5. Co-authored-by: Claude Fable 5 <[email protected]>
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.
Summary
renderToPipeableStream/renderToReadableStream) now ships Float sheet resources (<link rel="stylesheet" href precedence>,<style href precedence>) discovered after the shell flushed. Previously only the shell pass's head was ever written, so a sheet registered on a later resolution wave — a nested pending boundary's sheet, or an href computed from ause()resolution — appeared nowhere in the response.ReactDOMFloat-test.js:1923(child boundary stylesheet in the reveal),:2041and:2350(partial-boundary resources hoist to the parent boundary), each cited in the new tests.Why
Each resolution wave re-runs a full pass, but the wave loop only diffed
pass.cssEntries(scoped CSS) — the pass'sHeadBuffersheet registrations were folded into a head string for the shell and discarded on every later pass. React ships late boundary stylesheets with the boundary reveal instruction; Octane dropped them entirely. Reveal gating on sheet load (suspensey commits) remains a documented non-goal — the sheet just has to reach the document.Changes
packages/octane/src/runtime.server.tsHeadBuffer.sheetschanged fromMap<precedence, concatenatedHtml>to per-resourceMap<href, { precedence, html }>;headHtmlWithSheetsderives precedence groups at fold time (byte-identical output, first-encounter group order preserved).FullPassResultexposes the pass's sheet map;runStreamtracksflushedSheets(seeded from the shell pass) and each wave ships only new tags viafloatResourceChunk— real markup in a<div hidden data-oct-fr="…">carrier ahead of the wave's segment reveals, so no-JS consumers still get working CSS.$OCTRH(id)in the stream swap runtime hoists carrier tags intodocument.headwith the client's precedence-group insertion policy. A still-pending child boundary's sheet rides its parent's reveal wave (arm-root registrations run before the arm'suse()throws), matching React's partial-boundary hoisting.packages/octane/src/runtime.ts: once client Float resource state exists,resourceState()installswindow.$OCTFR;$OCTRHhands tags to it so one live authority keeps dedupe and group ordering through mid-stream hydration (no duplicates in either direction).resetFloatResourceState()clears it.packages/octane/src/constants.ts: new internalSTREAM_RESOURCE_ATTR(data-oct-fr).packages/octane/tests/_fixtures/float-stream.tsrx+ a "streamed late boundaries" describe infloat-resources.test.ts: dynamic-href sheet end-to-end (stream → head hoist → hydration adoption, CSP nonce on every emitted script), nested-boundary parent-wave hoisting, no re-ship of shell-flushed sheets, live-client-state routing race. Three cases were seen red pre-fix (dev + prod projects); the dedupe case was proven red against a deliberately broken implementation.docs/ssr.md+ design comments: the streamed-head divergence is narrowed — head elements and hints from late boundaries still recreate on hydration; the sheet family now streams.Performance: no per-node/per-render path touched — all additions are gated behind
pass.sheets !== null(null unless the page uses Float sheets), per-wave, or per-resource. The inline stream runtime grows 494 chars (~306 B gz alone) and is only emitted on responses with pending boundaries. No benchmark exercises Float SSR, so no wall-clock claim is made.Validation
pnpm format:check— changed files clean; the repo-wide run can race git-ignored test-generated.react-cache-ssr/files (pre-existing gap, follow-up task spawned)pnpm typecheckpnpm test— 21,106 passed; the handful of failures reproduce identically on unmodifiedmain(day-picker date-drift assertions, alien-signals/hook-form pinned-upstream suites, vaul browser drag — local-environment issues, follow-up task spawned) or pass in isolation (octane browser events, drei e2e — parallel-run contention); none touch this diff's code pathsfloat-resources.test.ts36/36 (dev + prod), streaming/SSR/stream-state suites 356/356, fizz conformance + hydration 806/806Risk / follow-ups
<script async src>Float resources still wait for hydration (unchanged, documented); follow-up if parity there matters.$OCTFRglobal — a pre-existing multi-copy hazard, unchanged.Provenance
agent-authored)🤖 Generated with Claude Code
Note
Medium Risk
Touches the streaming SSR protocol and client Float resource registration (
$OCTRH/$OCTFR), which affect head ordering and hydration adoption. Changes are gated behind Float sheet usage and covered by new end-to-end stream tests.Overview
Streaming SSR now ships Float sheet resources discovered after the shell, fixing FOUC on late boundaries and missing CSS for no-JS consumers.
Each resolution wave diffs per-resource sheet registrations (
href→ tag) against what already flushed and emits new tags in a hiddendata-oct-frcarrier ahead of segment reveals. Inline$OCTRHhoists them intodocument.headunder client precedence grouping; once live Float state exists, tags go through$OCTFRso dedupe stays in one authority. Nested pending sheets ride the parent's reveal wave.HeadBuffer.sheetsis now keyed by href (groups fold at emit time). Docs narrow the streamed-head gap to non-sheet head elements/hints; tests cover dynamic hrefs, nested hoisting, shell dedupe, and mid-stream client-state handoff.Reviewed by Cursor Bugbot for commit ad613eb. Bugbot is set up for automated code reviews on this repo. Configure here.