Repository navigation
feat: React 19 parity tranche — Float resources, root error callbacks, module hints, parity dispositions - #709
Merged
Merged
Conversation
…, module hints, parity dispositions Implements the React Float resource model (stylesheet precedence links and async script hoisting with SSR + hydration dedupe), preloadModule/preinitModule, the createRoot/hydrateRoot onCaughtError/onUncaughtError/onRecoverableError options (error codes 51-56 for the recoverable channel), and the unstable_Activity alias. Records partial pre-rendering and cache()/cacheSignal as documented ledger non-goals and documents the previously unlisted divergences in differences-from-react.md. Co-Authored-By: Claude Fable 5 <[email protected]>
…y return-position script resources The synchronous first root.render() and hydrateRoot's unowned render-throw path now consume the report through onUncaughtError exactly like the scheduled-flush path (the failed tree is still discarded and the root stays reusable), and requiresTemplateNormalization admits <script async src> so value-position (return <jsx>) trees reach the Float resource partition. Addresses both Bugbot findings on #709. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hydration recovery drops event delegation
- After releaseFailedHydration in the unowned onUncaughtError path, added claimRootContainer and registerDelegationTarget calls and passed the recovered token to makeRoot so the returned reusable root retains working delegated events and correct ownership tracking.
Or push these changes by commenting:
@cursor push 5cd61e66b4
Preview (5cd61e66b4)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -27499,7 +27499,8 @@
// retry client-remounts). Unowned hydration failures keep their existing
// behavior and rethrow untouched — unless this root's onUncaughtError
// consumes the report, which changes only the reporting: the failed
- // adoption is released identically and the caller gets a reusable root.
+ // tree is torn down and the caller gets a reusable root with delegation
+ // and container ownership restored.
const releaseFailedHydration = (): void => {
DOM_ROOT_DISPOSERS.delete(rootBlock);
unmountBlock(rootBlock, false);
@@ -27515,7 +27516,21 @@
if (rendererRegionOwnerForBlock(rootBlock) === null) {
if (!reportUncaughtError(rootBlock, error)) throw error;
releaseFailedHydration();
- return makeRoot(container, null, null, null, idState, renderReturnedValue, null, rootOptions);
+ // The recovered root is the caller's live handle — re-register
+ // delegation and reclaim the container so later .render() calls
+ // retain working delegated events and correct ownership tracking.
+ const recoveredToken = claimRootContainer(container);
+ registerDelegationTarget(container);
+ return makeRoot(
+ container,
+ null,
+ null,
+ null,
+ idState,
+ renderReturnedValue,
+ recoveredToken,
+ rootOptions,
+ );
}
try {
handleRenderError(rootBlock, error);You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 781a667. Configure here.
|
Bugbot Autofix prepared fixes for both issues found in the latest run.
Or push these changes by commenting: Preview (9abdd844bb)diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -16316,6 +16316,7 @@
(tag !== 'link' || isHoistableHeadElementNode(node))
)
return true;
+ if (selfNs !== 'svg' && headResourceKind(node) !== null) return true;
const childNs =
typeof tag === 'string' && !isComponentTag(node) ? nsForChildren(tag, parentNs) : parentNs;
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -27228,6 +27228,7 @@
// later recovery render. In particular, effects registered before the
// throw belong to an aborted render and must never reach a later flush.
if (!mountedRoot.disposed) unmountBlock(mountedRoot);
+ if (reportUncaughtError(mountedRoot, unhandled)) return;
throw unhandled;
}
root.unmount();You can send follow-ups to the cloud agent here. |
Collaborator
Author
|
Could not push Autofix changes. The PR branch has conflicting changes. |
…n failure When onUncaughtError consumes an unowned hydrateRoot render error, the returned root is rendered into directly — there is no host retry to re-register the container. Discard the failed adoption like createRoot's sync-mount failure (unmount + clear) but keep the delegation registration and container claim, passing the real ownerToken through so unmount() releases both exactly once. The owned hosted-island path keeps its full release. Click-through regression tests pin delegated events on recovered roots for both paths. Co-Authored-By: Claude Fable 5 <[email protected]>
trueadm
marked this pull request as ready for review
August 11, 2026 21:54
This was referenced Aug 11, 2026
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
<link rel="stylesheet" href precedence>and<script async src>at a component's body root are now global resources — hoisted todocument.head, deduped by href/src, stylesheet groups ordered by precedence (first-encounter group order, appended within a group), retained after unmount, emitted in buffered AND streamed SSR head output, and hydration-deduped (the first client call seeds from SSR-emitteddata-precedence/data-oct-restags).preloadModule/preinitModuleto the resource hints on bothoctaneandoctane/server.createRoot/hydrateRoot:onCaughtError(boundary claimed an error from the render/passive-effect/ref-attach channel),onUncaughtError(replaces the default report — the flush rethrow / effect-channelconsole.error— while the failed root's tree still unmounts), andonRecoverableError(structural hydration recovery, dev AND prod, coalesced per root per microtask burst). Error-only signature; noerrorInfo/componentStack.unstable_Activity→Activity(client + server + compiler tag whitelist), mirroringunstable_ViewTransition.resume/postpone) andcache()/cacheSignal()decisions as documented non-goals in the conformance ledger (27 entries flipped fromplanned), regeneratesdocs/react-parity-coverage.md, fixes the staleoctane/staticcomment, and documentshydrateRoot's missingformStateoption as an RSC-adjacent non-goal.docs/differences-from-react.mdnow covers the previously undocumented divergences —Context.Consumerabsence,<title>child concatenation, per-compile-site metadata dedupe, hidden-<Activity>scheduling (no offscreen lane), dropped stream options (progressiveChunkSize,namespaceURI),prerender's{html, css}shape vs React's{prelude}, theuseIdformat, theversionstring caveat,captureOwnerStack/unstable_batchedUpdates/gesture-VT non-goals, and the doctype wording fix.docs/ssr.mdanddocs/view-transitions.mdgain matching entries.Why
A deep React 19.2 parity audit (4 parallel area audits over the runtime, react-dom statics, SSR surface, and 19.1/19.2 additions) found the Float resource model was the largest functional gap (ReactDOMFloat-test.js is the single largest
plannedblock in the ledger at 131 cases), the root error callbacks were absent and undocumented, partial pre-rendering had contradictory ledger dispositions (32 non-goal vs 19 planned), and roughly a dozen real divergences existed in code but not indifferences-from-react.md, which promises "parity outside the documented differences".Changes
packages/octane/src/runtime.ts— Float resource insertion (stylesheetResource/scriptResource, DOM-seeded dedupe state, tier-3resetFloatResourceState),preloadModule/preinitModule,RootOptionserror callbacks +ROOT_ERROR_HANDLERSWeakMap (off the Block shape), caught/uncaught report wiring at the boundary-claim and default-report sites,noteRecoverableHydrationErrorat the structural hydration-recovery sites,unstable_Activityalias.packages/octane/src/runtime.server.ts—ssrStylesheetResource/ssrScriptResource,HeadBuffer.sheetsprecedence grouping (participates in both suspense-replay snapshot/rewind sites), head fold viaheadHtmlWithSheets, server module hints.packages/octane/src/compiler/compile.js—headResourceKindstatic classifier (link+rel=stylesheet+href+precedence; script+async+src,async={false}excluded, no handlers/children), script admission into the HeadHoist partition, emitter routing to the resource ABI (headBlock slot numbering unchanged),unstable_Activityin the builtin-import whitelist andisActivityLongForm.packages/octane/src/{index,server/index,static/index}.ts— exports and the correctedoctane/staticdoc comment.packages/octane/audit/react-conformance-ledger.json+docs/react-parity-coverage.md— 27 dispositions (FizzStatic postpone/resume → non-goal with the established rationale; ReactCache cache()/cacheSignal → non-goal) and the regenerated report.differences-from-react.md,ssr.md,view-transitions.md.tests/float-resources.test.ts(+fixture),tests/root-error-callbacks.test.ts(+fixture),tests/hydration/recoverable-callback.test.ts, module-hint cases intests/resource-hints.test.ts,unstable_Activitycase intests/activity.test.ts(+fixture).Contract and hot paths
Every new behavior is pay-per-use and off the hot paths: error-callback lookups run only on already-cold error/recovery paths behind a module-null check, handlers live in a WeakMap so the monomorphic Block shape is untouched, resource calls run once per authored resource element per render (dedupe-set hit after the first), and the compiler classifier adds two string compares per JSX child at compile time. No per-render/per-node work is added for components that use none of these features; no benchmark deltas are claimed and none are expected — the compiled output of code not using these features is byte-identical (head slot numbering deliberately preserved).
Known intentional bounds (documented in the diff): suspensey commits and
<style href precedence>are non-goals; resource classification is static (spreads keep the element path); deletion-phase teardown errors keep their existing default report;onRecoverableErrordoes not fire for attribute-level value patches (prod React cannot detect those at all).Validation
pnpm format:checkpnpm typecheckpnpm test— 18,480/18,481 passed. The one failure was a 20s timeout inpackages/phosphor-icons/tests/differential/parity.test.tsunder full-suite load; it passes in isolation in ~4s, passed in the previous full run with this same diff, and touches none of the changed code paths — reported here rather than papered over.float-resources(14),root-error-callbacks(18),recoverable-callback(10),resource-hints(16),activity.test(73),packed-consumer/production-error-bundle(13, exercises the error-code audit that gated the new catalog codes), plus neighbor sweeps over boundary/mismatch/error-handling/streaming/head-hydrate/ssr-suspense suites — all green in dev and prod compile projects.node scripts/react-parity/check.mjs --validate-only— ledger valid; coverage report verified byte-identical torenderCoverageReportover the committed inventories + edited ledger.pnpm sync— committed generated changes (CLI data, error-code modules).new Errormessages — the recoverable-error reports now use catalog codes 51–56 (minified in production, exactly like the rest of the framework's production errors).root.render()and hydrateRoot's unowned render-throw path now consume throughonUncaughtErrorlike the scheduled flush, andrequiresTemplateNormalizationadmits<script async src>so return-position trees classify resources. Full suite re-run: 18,490/18,491 (same phosphor-icons load-timeout flake, passes in isolation; spun off as a separate task), targeted + owned-path/hydration sweeps (1,840 tests) green,pnpm syncclean.ownerTokenpassed through; the hosted-island path's full release is unchanged). Full suite re-run: 18,492/18,493 (same phosphor flake), react-hosted/hydration/boundary sweep (1,204 tests) green.Risk / follow-ups
planned: flipping them tocoveredrequires exact-title conformance ports, which can now be written against the implemented behavior.prerenderToNodeStreamremains planned (comment now says so accurately).Provenance
agent-authored)Note
Medium Risk
Touches error-reporting and hydration-recovery paths plus SSR head emission, but changes are pay-per-use, off the hot path, and covered by targeted tests. Defaults without the new options remain unchanged.
Overview
Closes a major React 19 parity gap by treating body-root
<link rel="stylesheet" href precedence>and<script async src>as Float resources: hoisted intodocument.head, deduped by href/src, precedence-grouped, retained after unmount, and emitted in buffered/streamed SSR (with client hydration seeding).createRoot/hydrateRootgain React 19'sonCaughtError,onUncaughtError, andonRecoverableErroroptions (error-only; noerrorInfo). Providing them changes reporting only — recovery/unmount semantics stay the same. Also addspreloadModule/preinitModuleand aliasesunstable_Activity→Activity.Records partial pre-rendering,
cache()/cacheSignal(), andformStateas ledger non-goals, and documents previously missing divergences (Context.Consumer, title/metadata ownership, Activity scheduling, stream options,useId/version). Structural hydration recoveries now report via catalog codes 51–56.Reviewed by Cursor Bugbot for commit bb51576. Bugbot is set up for automated code reviews on this repo. Configure here.