Skip to content

Commit 8692ad9

Browse files
committed
fix(solid): an Errored fallback failing in the shell goes to the enclosing boundary
An `<Errored>` whose fallback failed while rendering (a hole that rejects, or a synchronous throw) for its content's error was left blank on the server: the boundary's error handler had already marked the error handled before rendering the fallback, so the fallback's own failure was dropped and the pull returned `undefined`. At shell level, with no `<Loading>`, the shell got a blank region with the errors recorded and no markup for them; an enclosing `<Errored>` serialized its record but never drew. The fallback's failure now passes up from the pull: an enclosing `<Errored>` draws its fallback in place of the region, and with none the request fails, the same for the async hole and its sync-throw twin. Server only; client bundles are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2
1 parent f14ce8d commit 8692ad9

9 files changed

Lines changed: 201 additions & 4 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
An `<Errored>` whose fallback fails while rendering (a hole that rejects, or a synchronous throw) now passes that failure to the enclosing boundary on the server, in the shell as well as in a streamed fragment. An outer `<Errored>` draws its fallback in place of the region, and with none the request fails. Before, the region was sent blank, with the errors recorded and no markup for them.

‎packages/solid/src/server/signals.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4512,6 +4512,7 @@ export function createErrorBoundary<T, U>(
45124512
() => {
45134513
let result: any;
45144514
let handled = false;
4515+
let fallbackThrew: { e: any } | undefined;
45154516
// Already showing the fallback for this request. Re-running would
45164517
// allocate new fallback ids and serialize the error again (#3920).
45174518
if (fallbackSettled) return fallbackResult;
@@ -4526,7 +4527,14 @@ export function createErrorBoundary<T, U>(
45264527
if (outcome === ESCALATE) return escalated(err, _parent);
45274528
if (outcome !== undefined) return renderOutcome(err, outcome, _parent);
45284529
handled = true;
4529-
result = handleError(err);
4530+
// Kept apart: a failure rendering the fallback is not this
4531+
// boundary's to handle (see the catch).
4532+
try {
4533+
result = handleError(err);
4534+
} catch (e) {
4535+
fallbackThrew = { e };
4536+
throw e;
4537+
}
45304538
throw err;
45314539
})
45324540
: runWithOwner(owner, fn);
@@ -4535,6 +4543,12 @@ export function createErrorBoundary<T, U>(
45354543
pulling = false;
45364544
if (err instanceof NotReadyError) throw err;
45374545
pending = undefined;
4546+
// The fallback failed rendering for the content's error: that
4547+
// failure is the enclosing boundary's, met in its own pull (an outer
4548+
// `<Errored>` draws its fallback; none, and the request fails), as
4549+
// when the fallback below throws. Never a blank in this boundary's
4550+
// place with the failure dropped.
4551+
if (fallbackThrew) throw fallbackThrew.e;
45384552
result = handled ? result : handleError(err);
45394553
}
45404554
return result;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "errored-shell-fallback-hole-async-failure-A-bare",
3+
"shell": "<div _hk=3><!--$--><h2 _hk=410>caught: <!--$-->no hint<!--/--></h2><!--/--><b>outer</b><span>tail</span></div><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"0\"]=$R[0]=($R[1]=($R[2]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p;_$HY.r[\"1\"]=$R[3]=($R[4]=$R[2]()).p;_$HY.r[\"2\"]=$R[5]=($R[6]=$R[2]()).p;($R[7]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[1],\"outer\");($R[9]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[8]=new Error(\"no user 7\"));$R[9]($R[6],$R[10]=new Error(\"no hint\"));_$HY.r[\"4000\"]=$R[8];_$HY.r[\"40\"]=$R[10];</script>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "errored-shell-fallback-hole-async-failure-A",
3+
"shell": "<div _hk=3><!--$--><h2 _hk=410>caught: <!--$-->no hint<!--/--></h2><!--/--><b>outer</b><span>tail</span></div><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"0\"]=$R[0]=($R[1]=($R[2]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p;_$HY.r[\"1\"]=$R[3]=($R[4]=$R[2]()).p;_$HY.r[\"2\"]=$R[5]=($R[6]=$R[2]()).p;($R[7]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[1],\"outer\");($R[9]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[8]=new Error(\"no user 7\"));$R[9]($R[6],$R[10]=new Error(\"no hint\"));_$HY.r[\"40010\"]=$R[8];_$HY.r[\"40\"]=$R[10];</script>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "errored-shell-fallback-hole-sync-failure-A-bare",
3+
"shell": "<div _hk=3><!--$--><h2 _hk=410>caught: <!--$-->no hint<!--/--></h2><!--/--><b>outer</b><span>tail</span></div><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"0\"]=$R[0]=($R[1]=($R[2]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p;_$HY.r[\"1\"]=$R[3]=($R[4]=$R[2]()).p;_$HY.r[\"2\"]=$R[5]=($R[6]=$R[2]()).p;($R[7]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[1],\"outer\");($R[9]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[8]=new Error(\"no user 7\"));$R[7]($R[6],\"\");_$HY.r[\"4000\"]=$R[8];_$HY.r[\"40\"]=$R[10]=new Error(\"no hint\");</script>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "errored-shell-fallback-hole-sync-failure-A",
3+
"shell": "<div _hk=3><!--$--><h2 _hk=410>caught: <!--$-->no hint<!--/--></h2><!--/--><b>outer</b><span>tail</span></div><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"0\"]=$R[0]=($R[1]=($R[2]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p;_$HY.r[\"1\"]=$R[3]=($R[4]=$R[2]()).p;_$HY.r[\"2\"]=$R[5]=($R[6]=$R[2]()).p;($R[7]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[1],\"outer\");($R[9]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[8]=new Error(\"no user 7\"));$R[7]($R[6],\"\");_$HY.r[\"40010\"]=$R[8];_$HY.r[\"40\"]=$R[10]=new Error(\"no hint\");</script>",
4+
"rest": ""
5+
}

‎packages/web/test/harness/scenarios.tsx‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,73 @@ export const lateParkedFailures: ParkedFailure[] = [false, true].map(A => ({
18521852
late: true
18531853
}));
18541854

1855+
// ---------------------------------------------------------------------------
1856+
// The #4316 failure at shell level, no `<Loading>` anywhere: `B`, an
1857+
// `<Errored>` around a read that rejects (5ms), whose fallback's own hole
1858+
// fails too — `hole: "async"` rejects at 10ms, `hole: "sync"` is its twin,
1859+
// a fallback that throws synchronously. The shell waits for both (and for
1860+
// `<b>{outer()}</b>`, 15ms). B's fallback's failure is the next boundary's:
1861+
// with `A`, an `<Errored>` around B (`section`: markup between), A's
1862+
// fallback is drawn in the shell; with none, the request fails — both as
1863+
// the twin does, never a blank region with B's and A's errors recorded and
1864+
// no markup for either.
1865+
export type ShellFallbackFailure = { hole: "async" | "sync"; A: boolean; section: boolean };
1866+
export const shellFallbackFailureName = (o: ShellFallbackFailure) =>
1867+
`errored-shell-fallback-hole-${o.hole}-failure${o.A ? "-A" : ""}${o.section ? "" : "-bare"}`;
1868+
export function shellFallbackFailure(o: ShellFallbackFailure) {
1869+
return function ShellFallbackFailure() {
1870+
const outer = createMemo(async () => {
1871+
await sleep(15);
1872+
return "outer";
1873+
});
1874+
const user = createMemo(async (): Promise<string> => {
1875+
await sleep(5);
1876+
throw new Error("no user 7");
1877+
});
1878+
// The twin takes the async memo's owner slot too, so both variants'
1879+
// hydration keys line up.
1880+
const slot = createMemo(async (): Promise<string> => {
1881+
if (o.hole === "sync") return "";
1882+
await sleep(10);
1883+
throw new Error("no hint");
1884+
});
1885+
const hint =
1886+
o.hole === "async"
1887+
? slot
1888+
: (): string => {
1889+
throw new Error("no hint");
1890+
};
1891+
const B = () => (
1892+
<Errored
1893+
fallback={(e: any) => (
1894+
<p>
1895+
failed: {e().message} {hint()}
1896+
</p>
1897+
)}
1898+
>
1899+
<span>user:{user()}</span>
1900+
</Errored>
1901+
);
1902+
const mid = () => (o.section ? <section>{B()}</section> : B());
1903+
const region = () =>
1904+
o.A ? (
1905+
<Errored fallback={(e: any) => <h2>caught: {e().message}</h2>}>{mid()}</Errored>
1906+
) : (
1907+
mid()
1908+
);
1909+
return (
1910+
<div>
1911+
{region()}
1912+
<b>{outer()}</b>
1913+
<span>tail</span>
1914+
</div>
1915+
);
1916+
};
1917+
}
1918+
export const shellFallbackFailures: ShellFallbackFailure[] = (["async", "sync"] as const).flatMap(
1919+
hole => [false, true].flatMap(A => [false, true].map(section => ({ hole, A, section })))
1920+
);
1921+
18551922
// ---------------------------------------------------------------------------
18561923
// #3414: a sync throw the SERVER catches, with a zero-arg fallback thunk
18571924
// (`fallback={() => <Fallback />}`), inside an enclosing boundary. Errored

‎packages/web/test/hydration/errored-parked-async-outcome-4306.spec.tsx‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ import {
4040
lateParkedFailures,
4141
parkedFailure,
4242
parkedFailureName,
43+
shellFallbackFailures,
44+
shellFallbackFailure,
45+
shellFallbackFailureName,
4346
type FallbackHoleFailure
4447
} from "../harness/scenarios.jsx";
4548

@@ -242,8 +245,10 @@ describe("#4316: the Errored fallback's own hole fails", () => {
242245
// (the inner `<Loading>` shows its fallback, the twin's the outer's), so
243246
// what is compared is that it halted and on what. Warnings are this
244247
// variant's alone: the streamed twin with an `<Errored>` around a pending
245-
// read misses its fallback key while it hydrates the pending fragment (a
246-
// client id misalignment of that shape, not of the parked failure).
248+
// read misses its fallback key while it hydrates the pending fragment —
249+
// the core's retry of the errored read, once the fragment releases, is
250+
// taken for a client write by readSerializedOrCompute's latched branch,
251+
// which refetches; #4319's served pass is what keeps that read latched.
247252
describe("#4316: a fragment failing while parked in a pending fragment", () => {
248253
const comparable = (r: Outcome) => ({
249254
...r,
@@ -290,6 +295,38 @@ describe("#4316: a fragment failing while parked in a pending fragment", () => {
290295
}
291296
});
292297

298+
// The same failure at shell level, no `<Loading>`: the outer `<Errored>`
299+
// caught B's fallback's failure on the server; the client claims its
300+
// fallback, ending as the sync-throw twin.
301+
describe("#4316: the Errored fallback's own hole fails in the shell", () => {
302+
for (const o of shellFallbackFailures) {
303+
if (o.hole !== "async" || !o.A) continue;
304+
for (const mode of ["loaded", "streamed"] as const) {
305+
test(`${shellFallbackFailureName(o)} [${mode}] ends as its sync-throw twin`, async () => {
306+
const twinOf = { ...o, hole: "sync" as const };
307+
const outcome = await replay(
308+
shellFallbackFailureName(o),
309+
shellFallbackFailure(o),
310+
mode,
311+
"h2"
312+
);
313+
const twin = await replay(
314+
shellFallbackFailureName(twinOf),
315+
shellFallbackFailure(twinOf),
316+
mode,
317+
"h2"
318+
);
319+
expect(outcome).toEqual(twin);
320+
expect(outcome.text).toBe("caught: no hintoutertail");
321+
expect(outcome.halted).toBe(false);
322+
expect(outcome.warnings).toBe(0);
323+
expect(outcome.uncaught).toEqual([]);
324+
expect(outcome.claimed).toBe(true);
325+
});
326+
}
327+
}
328+
});
329+
293330
function textOfHtml(html: string) {
294331
const el = document.createElement("div");
295332
el.innerHTML = html;

‎packages/web/test/server/hydration-harness.spec.tsx‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {
2525
parkedFailures,
2626
lateParkedFailures,
2727
parkedFailure,
28-
parkedFailureName
28+
parkedFailureName,
29+
shellFallbackFailures,
30+
shellFallbackFailure,
31+
shellFallbackFailureName
2932
} from "../harness/scenarios.jsx";
3033
import { recordStream, writeArtifact } from "./artifact-recorder.js";
3134

@@ -151,3 +154,54 @@ describe("hydration parity harness — fragment failure parked in a pending frag
151154
}
152155
});
153156
});
157+
158+
// The #4316 failure at shell level, no <Loading>: an Errored fallback whose
159+
// own hole fails, async and its sync-throw twin. Recorded (caught by an
160+
// outer <Errored>) for test/hydration/errored-parked-async-outcome-4306
161+
// .spec.tsx. Here: the shell carries what the twin's does — the outer
162+
// Errored's fallback, never a blank region with the errors recorded and no
163+
// markup for them — and with no outer Errored the request fails, as the
164+
// twin's does.
165+
describe("hydration parity harness — Errored fallback hole failure in the shell", () => {
166+
const visible = (full: string) =>
167+
full
168+
.replace(/<script[\s\S]*?<\/script>/g, "")
169+
.replace(/<[^>]*>/g, " ")
170+
.split(/\s+/)
171+
.filter(Boolean)
172+
.join(" ");
173+
const recorded = new Map<string, { text: string; errors: string[] }>();
174+
for (const o of shellFallbackFailures) {
175+
const name = shellFallbackFailureName(o);
176+
test(name, async () => {
177+
const App = shellFallbackFailure(o);
178+
const errors: string[] = [];
179+
const { shell, rest } = await storage.run(makeEvent(), () =>
180+
recordStream(() => <App />, {
181+
onError: (e: unknown) => void errors.push(e instanceof Error ? e.message : String(e))
182+
})
183+
);
184+
recorded.set(name, { text: visible(shell + rest), errors });
185+
expect(rest).toBe("");
186+
expect(errors).toContain("no hint");
187+
if (o.A) {
188+
writeArtifact(name, { name, shell, rest });
189+
expect(shell).toContain("caught: <!--$-->no hint<!--/--></h2>");
190+
expect(shell).toContain("<b>outer</b>");
191+
expect(shell).not.toContain("<section");
192+
expect(shell).not.toContain("failed:");
193+
} else {
194+
// B's fallback failed with nothing above it: the request fails.
195+
expect(shell).toBe("");
196+
}
197+
});
198+
}
199+
test("the async variant sends what its sync-throw twin sends", () => {
200+
for (const o of shellFallbackFailures) {
201+
if (o.hole !== "async") continue;
202+
const name = shellFallbackFailureName(o);
203+
const twin = shellFallbackFailureName({ ...o, hole: "sync" });
204+
expect(recorded.get(name), name).toEqual(recorded.get(twin));
205+
}
206+
});
207+
});

0 commit comments

Comments
 (0)