Skip to content

Commit 990f942

Browse files
committed
wip(solid): V3 — V1 plus a minimal effect re-run hook ending the hold (#4273)
Measurement variant on V1 (not on V2): effects the content creates in the pass end the hold on their first re-run, with no failure detection in the wrapper (a fallback built before the hold means the content failed) and no try/finally. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent f384481 commit 990f942

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎packages/solid/src/client/hydration.ts‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,13 +1285,16 @@ 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 through the hydration pass behind a hold: a
1289-
// render effect in the content throwing the server's error until
1290-
// hydration ends or reset(), disposed with the content when it re-runs
1291-
// (#4273).
1288+
// the server's fallback up behind a hold: a render effect in the content
1289+
// throwing the server's error until reset() — which a re-run of an
1290+
// effect the content created calls — disposed with the content when it
1291+
// re-runs (#4273).
12921292
if (err !== undefined) {
12931293
_unclaimed = true;
1294-
let o: any, held: any;
1294+
let o: any, held: any, r: any;
1295+
const prev = _hold;
1296+
// An effect the content creates now re-running: an input changed.
1297+
_hold = () => held && r();
12951298
const read = coreErrorBoundary(
12961299
() => {
12971300
(o = getOwner() as any)._uc = 1;
@@ -1300,25 +1303,23 @@ function hydratedCreateErrorBoundary<T, U>(
13001303
(e, reset) =>
13011304
fallback(
13021305
e,
1303-
(held = () => {
1306+
(r = () => {
13041307
held = 0;
13051308
reset();
13061309
})
13071310
)
13081311
);
1312+
_hold = prev;
13091313
// No fallback yet: the content ran clean.
1310-
if (!held && (held = 1)) {
1311-
const [g, end] = coreSignal(true);
1312-
onHydrationEnd(() => end(false));
1314+
if (!r && (held = 1))
13131315
runWithOwner(o, () =>
13141316
coreRenderEffect(
13151317
() => {
1316-
if (g() && held) throw err;
1318+
if (held) throw err;
13171319
},
13181320
() => {}
13191321
)
13201322
);
1321-
}
13221323
return read;
13231324
}
13241325
}
@@ -1350,7 +1351,15 @@ function hydratedCreateRoot(init: Function, options?: { id?: string; transparent
13501351

13511352
// --- Hydration-aware effect implementations ---
13521353

1354+
let _hold: (() => void) | undefined;
1355+
13531356
function hydratedEffect(coreFn: Function, compute: any, effectFn: any, options?: any) {
1357+
const h = _hold;
1358+
if (h) {
1359+
const c = compute;
1360+
let ran: any;
1361+
compute = (prev: any) => (ran ? h() : (ran = 1), c(prev));
1362+
}
13541363
if (!sharedConfig.hydrating || options?.transparent || noHydrationId())
13551364
return coreFn(compute, effectFn, options);
13561365

0 commit comments

Comments
 (0)