Skip to content

Commit 5cd61e6

Browse files
committed
fix: re-register delegation and container claim after unowned hydration recovery
When onUncaughtError consumes an unowned hydrateRoot failure, releaseFailedHydration correctly tears down the failed tree but also unregisters event delegation and releases the container claim. The returned root is the caller's live handle — subsequent .render() calls need working delegated events and proper ownership tracking. Re-register both after the release so the recovered root behaves like createRoot's sync-failure recovery path, which keeps delegation and claim intact.
1 parent 781a667 commit 5cd61e6

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27499,7 +27499,8 @@ export function hydrateRoot(
2749927499
// retry client-remounts). Unowned hydration failures keep their existing
2750027500
// behavior and rethrow untouched — unless this root's onUncaughtError
2750127501
// consumes the report, which changes only the reporting: the failed
27502-
// adoption is released identically and the caller gets a reusable root.
27502+
// tree is torn down and the caller gets a reusable root with delegation
27503+
// and container ownership restored.
2750327504
const releaseFailedHydration = (): void => {
2750427505
DOM_ROOT_DISPOSERS.delete(rootBlock);
2750527506
unmountBlock(rootBlock, false);
@@ -27515,7 +27516,21 @@ export function hydrateRoot(
2751527516
if (rendererRegionOwnerForBlock(rootBlock) === null) {
2751627517
if (!reportUncaughtError(rootBlock, error)) throw error;
2751727518
releaseFailedHydration();
27518-
return makeRoot(container, null, null, null, idState, renderReturnedValue, null, rootOptions);
27519+
// The recovered root is the caller's live handle — re-register
27520+
// delegation and reclaim the container so later .render() calls
27521+
// retain working delegated events and correct ownership tracking.
27522+
const recoveredToken = claimRootContainer(container);
27523+
registerDelegationTarget(container);
27524+
return makeRoot(
27525+
container,
27526+
null,
27527+
null,
27528+
null,
27529+
idState,
27530+
renderReturnedValue,
27531+
recoveredToken,
27532+
rootOptions,
27533+
);
2751927534
}
2752027535
try {
2752127536
handleRenderError(rootBlock, error);

0 commit comments

Comments
 (0)