[2.0.4] SSR: `<Errored>` sends a blank instead of its fallback when the failing `<Loading>` is not its only content (follow-up to #4287)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- backend, testing-qa
Direzione di ricerca
Start with the server createErrorBoundary renderOutcome implementation in packages/solid/src/server/signals.ts:4409 and the PostflushRejectionNested scenario in packages/web/test/harness/scenarios.tsx:1585. Compare the held-shell behavior with the existing ESCALATE and FragmentContainer.region path described in the issue. The proposed before-shell fix requires synchronous fallback markup; done means the nested shape renders the error fallback before the shell flush, with tests covering the behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Since #4303, when an async read under a <Loading> rejects during renderToStream, the <Errored> around it draws its fallback on the server and the hydrating client adopts it, but only when the <Loading> is the <Errored>'s whole content. With markup between them (<Errored><b><Loading>…</Loading></b></Errored>) or a sibling beside the <Loading>, the server sends a blank instead: before the shell, the shell keeps <b></b>; after it, an empty <template id="…" e></template>. The fallback only appears once the client hydrates, and never without JS.
Playground
Open in the Solid playground (2.0.4). The page loads solid-js and @solidjs/web a second time as their server builds (https://esm.sh/…@2.0.4?conditions=worker), runs renderToStream in the page with the server template helpers, and prints the stream for each case. Nothing to click. The standalone Node repro below gives the same output.
Repro
With [email protected] and @solidjs/[email protected] installed, run node no-compiler.mjs <direct|element> <ms>. It uses the server build and the server template helpers, so no compiler is needed. ms is when the read rejects: 200 is after the shell, 1 is before it.
import { createMemo, Loading, Errored, createComponent } from "solid-js";
import { renderToStream, ssr, escape, markSafeError } from "@solidjs/web";
const [shape = "element", ms = "200"] = process.argv.slice(2);
let reject;
const p = new Promise((_, j) => (reject = j));
p.catch(() => {});
function App() {
const user = createMemo(() => p);
const loading = () =>
createComponent(Loading, {
fallback: ssr(["<i>loading</i>"]),
get children() { return ssr(["<u>", "</u>"], () => escape(user().name)); }
});
return ssr(["<main>", "</main>"], createComponent(Errored, {
fallback: e => ssr(["<p>failed: ", "</p>"], escape(e().message)),
// direct: <Errored><Loading>…; element: <Errored><b><Loading>…
get children() { return shape === "direct" ? loading() : ssr(["<b>", "</b>"], loading()); }
}));
}
renderToStream(() => createComponent(App, {})).pipe({
write: c => console.log(c.replace(/<script>[\s\S]*?<\/script>/g, "")),
end() {}
});
setTimeout(() => reject(markSafeError(new Error("no user"))), Number(ms));
Expected
Every shape should end with the error fallback in place of the <Errored>'s content. That is what direct gets and what a client render shows: <main><p>failed: no user</p></main>. Before the shell, nothing has been sent yet, so the fallback can go straight into the shell.
Actual
On 2.0.4, with <script> tags removed:
$ node no-compiler.mjs direct 200
<main><template id="pl-100"></template><i>loading</i><!--pl-100--></main>
<template id="100" e><p>failed: no user</p></template>
$ node no-compiler.mjs element 200
<main><b><template id="pl-100"></template><i>loading</i><!--pl-100--></b></main>
<template id="100" e></template>
$ node no-compiler.mjs direct 1
<main><p>failed: no user</p></main>
$ node no-compiler.mjs element 1
<main><b></b></main>
Compiled JSX gives the same output (with _hk ids), whether the element is written inline or returned by a component. A sibling beside the <Loading> does too (checked on main 50a4bfd). A component that returns the <Loading> alone is fine. In Chromium without a client bundle, element stays <main><b></b></main>.
Versions: 2.0.4, 2.0.0, 2.0.0-rc.23, rc.22 and rc.21 (npm) and main (ad1f561, 50a4bfd) all give the output above. No version tested draws the fallback for the nested shape, so this is not a regression.
Why this is a leftover
- #4303's "Before" describes this blank as the bug it fixed ("Until hydration the browser showed neither the loading fallback nor the error fallback"). Its "After" then keeps it, without a reason: "With markup between the two boundaries (
<Errored><section><Loading>), the position stays blank and the client renders the failure, as before." - The hydration harness pins only the after-shell blank, and describes it without saying why:
scenarios.tsx:1585(PostflushRejectionNested). No test pins the before-shell blank. - For server components the rule is already the opposite: "the position shows what the SERVER rendered for the outcome, never a blank, never a client-invented state" (
hydration.ts:396).
Cause
The server createErrorBoundary's renderOutcome (signals.ts:4409) answers the failing <Loading> only when its content is exactly that <Loading>'s placeholder. Otherwise failFragment settles the fragment as failed with no content:
- After the shell, that settled fragment is the empty
<template e>above. - Before the shell, the placeholder is inlined away as
"". The<Errored>'s markup is already in the held shell as a finished string, and no error is recorded at the<Errored>.
Since #4318, a nested <Errored> can already replace its markup with its fallback when that markup sits inside a <Loading> fragment that is still pending (ESCALATE, FragmentContainer.region). The held shell does not get the same treatment.
Proposed fixes
- (a) Before the shell flush, when nothing has been sent yet. Draw the
<Errored>'s fallback in the shell in place of its whole markup. This reuses the #4316 region machinery (escalated,FragmentContainer.region), with the unflushed shell treated as one more container. The error is serialized at the<Errored>id, so the client adopts the fallback as it does for the direct shape. To be conservative, this happens only when the fallback's markup is ready synchronously. Otherwise the behaviour stays as it is today, so the shell is never delayed. A branch with this change and tests exists and can be opened as a PR. - (b) After the shell flush. The
<Errored>'s markup is already out, and an<Errored>emits no markers of its own. This would need markers around the<Errored>region in the shell and a streamed region swap. Open questions: the hydration scaffolding for a client that hydrated mid-stream, leftoverpl-*placeholders and markers, and reveal groups. This is an enhancement, not part of (a). - (c) If neither is wanted, document the limit under
<Errored>and<Loading>and indocumentation/solid-2.0/12-ssr-http.md.
Related
- #4287 (closed): the direct shape, fixed by #4303.
- #4303 (merged): "The fallback is drawn only for the direct shape; nested markup stays blank."
- #4316 / #4318: a fallback's own failure goes to the next boundary up. #4318 added the escalation path that fix (a) reuses.
- Lingua principale
- TypeScript
- Stelle
- 37k
- Fork
- 1.2k
- Merge medio
- 8h 43m
- PR unite (30g)
- 365
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesForse già presa @MilindChatrabhuji l’ha presa 2 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
activepieces/activepieces#17974 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
OHDSI/Data2Evidence#3777 ·
I maintainer di solito rispondono entro 3 giorni
-
bug enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
AOSSIE-Org/PictoPy#1802 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Termix-SSH/Plugin-Snippets#26 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agent-reported bug from-app needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nightly-labs/openbot#20504 ·
I maintainer di solito rispondono entro 1 giorno