[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)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- backend, testing-qa
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
activepieces/activepieces#17974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OHDSI/Data2Evidence#3777 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Termix-SSH/Plugin-Snippets#26 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-reported bug from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nightly-labs/openbot#20504 ·
Maintainer thường phản hồi trong vòng 1 ngày