@@ -295,6 +295,8 @@ function hydrationDevPeekNextContextId(): string | undefined {
295295 return o && o . id != null ? peekNextChildId ( o ) : undefined ;
296296}
297297
298+ const noop = ( ) => { } ;
299+
298300// === Hydration phase API ===
299301
300302let _hydrationEndCallbacks : ( ( ) => void ) [ ] | null = null ;
@@ -304,18 +306,14 @@ let _snapshotRootOwner: Owner | null = null;
304306// The boundary owner whose resume window is open (null during a root pass,
305307// which claims everything). Reached as `sharedConfig.isClaiming`.
306308let _claimOwner : Owner | null = null ;
307- // Set once a hydrated `<Errored>` runs content the server drew no markup
308- // for: that content's owner (`_uc`) claims nothing.
309- let _unclaimed = false ;
310309function isClaiming ( ) : boolean {
311- if ( ! _claimOwner && ! _unclaimed ) return true ;
310+ if ( ! _claimOwner ) return true ;
312311 let owner : Owner | null = getOwner ( ) ;
313312 while ( owner ) {
314- if ( ( owner as any ) . _uc ) return false ;
315313 if ( owner === _claimOwner ) return true ;
316314 owner = owner . _parent ;
317315 }
318- return ! _claimOwner ;
316+ return false ;
319317}
320318
321319/** @internal — shared with the store adapter module (store-hydration.ts). */
@@ -425,7 +423,6 @@ export function onHydrationEnd(callback: () => void): void {
425423function drainHydrationCallbacks ( ) {
426424 if ( _hydrationDone ) return ;
427425 _hydrationDone = true ;
428- _unclaimed = false ;
429426 _doneValue = true ;
430427 clearSnapshots ( ) ;
431428 setSnapshotCapture ( false ) ;
@@ -563,7 +560,7 @@ export function subFetch<T>(fn: (prev?: T) => any, prev?: T) {
563560 // the MockPromise swap can't intercept it), so a rejecting compute
564561 // (#2997: server-rejected async adopted on the client) must be observed
565562 // here or it surfaces as an unhandled rejection.
566- if ( result && typeof result . then === "function" ) result . then ( undefined , ( ) => { } ) ;
563+ if ( result && typeof result . then === "function" ) result . then ( undefined , noop ) ;
567564 return result ;
568565 } finally {
569566 window . fetch = ogFetch ;
@@ -608,7 +605,7 @@ export function readHydratedValue(initP: any, refresh: () => void, options?: any
608605 // The stamp is the consumption: nothing ever `.then`s the serialized
609606 // promise itself, so observe its rejection here or the deserialized
610607 // record surfaces as an unhandled rejection (#2997).
611- if ( typeof initP . then === "function" ) initP . then ( undefined , ( ) => { } ) ;
608+ if ( typeof initP . then === "function" ) initP . then ( undefined , noop ) ;
612609 throw initP . v ;
613610 }
614611 if ( initP . s === 1 ) return initP . v ;
@@ -1289,31 +1286,30 @@ function hydratedCreateErrorBoundary<T, U>(
12891286 // throwing the server's error until reset(), disposed with the content
12901287 // when it re-runs (#4273).
12911288 if ( err !== undefined ) {
1292- _unclaimed = true ;
1293- let o : any , held : any ;
1289+ // The content's owner, until a fallback is built.
1290+ let o : any ;
12941291 const read = coreErrorBoundary (
12951292 ( ) => {
1296- ( o = getOwner ( ) as any ) . _uc = 1 ;
1297- return fn ( ) ;
1293+ const prev = _claimOwner ;
1294+ o = getOwner ( ) ;
1295+ // A claim window over no owner: nothing under it claims.
1296+ _claimOwner = { } as Owner ;
1297+ try {
1298+ return fn ( ) ;
1299+ } finally {
1300+ _claimOwner = prev ;
1301+ }
12981302 } ,
1299- ( e , reset ) =>
1300- fallback (
1301- e ,
1302- ( held = ( ) => {
1303- held = 0 ;
1304- reset ( ) ;
1305- } )
1306- )
1303+ ( e , reset ) => ( ( o = 0 ) , fallback ( e , reset ) )
13071304 ) ;
1308- // No fallback yet: the content ran clean.
1309- if ( ! held && ( held = 1 ) )
1305+ // No fallback yet: the content ran clean. Hold the server's fallback
1306+ // behind a render effect throwing its error once — until reset()
1307+ // re-runs it, or the content re-runs and disposes it.
1308+ if ( o )
13101309 runWithOwner ( o , ( ) =>
1311- coreRenderEffect (
1312- ( ) => {
1313- if ( held ) throw err ;
1314- } ,
1315- ( ) => { }
1316- )
1310+ coreRenderEffect ( ( ) => {
1311+ if ( o ) throw ( ( o = 0 ) , err ) ;
1312+ } , noop )
13171313 ) ;
13181314 return read ;
13191315 }
@@ -2640,7 +2636,7 @@ function rejectTruncatedRefs(hy: any) {
26402636 entry . p . v = err ;
26412637 // Guard the harness itself against an unhandled-rejection report; the
26422638 // consumer observes the rejection through its own chain.
2643- entry . p . then ( undefined , ( ) => { } ) ;
2639+ entry . p . then ( undefined , noop ) ;
26442640 } ;
26452641 for ( const key in R ) {
26462642 const value = R [ key ] ;
@@ -2909,7 +2905,7 @@ function hydratedCreateLoadingBoundary<T, U>(
29092905 // branch takes over — swallow it so a rejected fragment (error
29102906 // finalize or a client-hole handoff) doesn't surface as an
29112907 // unhandled rejection.
2912- ( fr as Promise < never > ) . catch ?.( ( ) => { } ) ;
2908+ ( fr as Promise < never > ) . catch ?.( noop ) ;
29132909 // Observe: the fresh render is a "recovery" record; prod folds the
29142910 // branch and `recover` with it.
29152911 const resumeRejected = IS_OBSERVE
0 commit comments