@@ -1285,43 +1285,37 @@ function hydratedCreateErrorBoundary<T, U>(
12851285 // content runs now with its data adopted by id but claiming no DOM —
12861286 // the markup is the fallback's — so what it throws is the client's
12871287 // error, held and tracked like any other. Content that runs clean keeps
1288- // the server's fallback up behind a hold: a render effect throwing the
1289- // server's error until reset() — which a re-run of an effect the content
1290- // created (an input changed) calls — and disposed with the content when
1291- // it re-runs (#4273).
1288+ // the server's fallback up behind a hold: a render effect in the content
1289+ // throwing the server's error until reset(), disposed with the content
1290+ // when it re-runs (#4273).
12921291 if ( err !== undefined ) {
12931292 _unclaimed = true ;
1294- const h : Hold = { } ;
1295- return coreErrorBoundary (
1293+ let o : any , held : any ;
1294+ const read = coreErrorBoundary (
12961295 ( ) => {
1297- const o = getOwner ( ) as any ;
1298- if ( o . _uc ) return fn ( ) ;
1299- o . _uc = 1 ;
1300- const prev = _hold ;
1301- _hold = h ;
1302- try {
1303- var v = fn ( ) ;
1304- } finally {
1305- _hold = prev ;
1306- }
1307- if ( ( h . h = ! h . f ) )
1308- coreRenderEffect (
1309- ( ) => {
1310- if ( h . h ) throw err ;
1311- } ,
1312- ( ) => { }
1313- ) ;
1314- return v ;
1296+ ( o = getOwner ( ) as any ) . _uc = 1 ;
1297+ return fn ( ) ;
13151298 } ,
13161299 ( e , reset ) =>
13171300 fallback (
13181301 e ,
1319- ( h . r = ( ) => {
1320- h . h = false ;
1302+ ( held = ( ) => {
1303+ held = 0 ;
13211304 reset ( ) ;
13221305 } )
13231306 )
13241307 ) ;
1308+ // No fallback yet: the content ran clean.
1309+ if ( ! held && ( held = 1 ) )
1310+ runWithOwner ( o , ( ) =>
1311+ coreRenderEffect (
1312+ ( ) => {
1313+ if ( held ) throw err ;
1314+ } ,
1315+ ( ) => { }
1316+ )
1317+ ) ;
1318+ return read ;
13251319 }
13261320 }
13271321 return coreErrorBoundary ( fn , fallback ) ;
@@ -1352,28 +1346,7 @@ function hydratedCreateRoot(init: Function, options?: { id?: string; transparent
13521346
13531347// --- Hydration-aware effect implementations ---
13541348
1355- // An errored boundary's content run in the hydration pass (see
1356- // hydratedCreateErrorBoundary): `f` — an effect of it threw on the client
1357- // (or went pending); `h` — the server's fallback is held over it; `r` — the
1358- // boundary's reset, which ends the hold.
1359- type Hold = { f ?: boolean ; h ?: boolean ; r ?: ( ) => void } ;
1360- let _hold : Hold | undefined ;
1361-
13621349function hydratedEffect ( coreFn : Function , compute : any , effectFn : any , options ?: any ) {
1363- const h = _hold ;
1364- if ( h ) {
1365- const c = compute ;
1366- let ran = false ;
1367- compute = ( prev : any ) => {
1368- if ( ran && h . h ) h . r ! ( ) ;
1369- ran = true ;
1370- try {
1371- return c ( prev ) ;
1372- } catch ( e ) {
1373- throw ( ( h . f = true ) , e ) ;
1374- }
1375- } ;
1376- }
13771350 if ( ! sharedConfig . hydrating || options ?. transparent || noHydrationId ( ) )
13781351 return coreFn ( compute , effectFn , options ) ;
13791352
0 commit comments