[2.0 rc.14 / next] SSR: a rejection contained by `<Errored>` is still an unhandled rejection when an async sibling shares its children slot (exits Node)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- nodejs, typescript
- 领域
- frontend
调研方向
错误在 packages/solid/src/server/signals.ts 中的 createErrorBoundary 里抛出,那里创建了合并的 Promise.all(pending.p) 并以 NotReadyError 的形式抛出。请从那里开始,检查当同级节点让插槽保持 pending 时,为什么没有任何代码等待这个 Promise。运行 issue 中的复现步骤,它应当显示 Error: boom 作为未处理的拒绝。完成的标准是:不再报告未处理的拒绝,HTML 输出保持不变,并且仍然渲染 Errored 回退内容。
由索引模型根据 Issue 内容生成。
描述
Summary
During renderToStream, an async read that rejects under <Errored> is contained (the fallback renders), but the rejection is also left unhandled when the boundary shares a {props.children} slot with an async sibling. Node's default --unhandled-rejections=throw then ends the process. Another <Errored> around the whole tree does not help: the error is not escaping the render, it is an internal promise nobody handles.
Reproduction
import { renderToStream } from "@solidjs/web";
import { createMemo, Errored, Loading } from "solid-js";
import type { ParentProps } from "solid-js";
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
process.on("unhandledRejection", (reason) => console.log("unhandled:", String(reason)));
function Layout(props: ParentProps) {
return <main>{props.children}</main>;
}
function Fails() {
const value = createMemo(async () => {
await delay(5);
throw new Error("boom");
});
return <p>{value()}</p>;
}
function Later() {
const value = createMemo(async () => {
await delay(20);
return "later";
});
return <p>{value()}</p>;
}
renderToStream(() => (
<Loading fallback={<p>loading</p>}>
<Layout>
<Errored fallback={(_error) => <p>failed</p>}>
<Fails />
</Errored>
<Later />
</Layout>
</Loading>
)).then((html) => console.log(html));
| HTML | unhandledRejection |
|
|---|---|---|
| as above | <main><p>failed</p><p>later</p></main> |
Error: boom |
wrapped in another <Errored> |
same | Error: boom |
<Later /> removed |
<main><p>failed</p></main> |
none |
<Later /> after </Layout> |
<main><p>failed</p></main><p>later</p> |
none |
no <Layout> (both directly in <Loading>) |
<p>failed</p><p>later</p> |
none |
Without the handler, Node exits. Reproduces on 2.0.0-rc.14, also with #3936 applied; the code below is unchanged on next.
Cause
The server boundary's resolve (packages/solid/src/server/signals.ts, createErrorBoundary) throws a combined promise while its holes are pending:
const all: any = Promise.all(pending.p);
if (pending.p.some(p => (p as any).$clientHole)) all.$clientHole = true;
throw new NotReadyError(all);
When the sibling keeps the slot pending and the slot is retried, nothing awaits that all any more, so its rejection is reported even though the boundary handled the error and rendered its fallback.
Expected
A rejection that <Errored> contains is handled, as for a rejecting direct child of <Loading> (#3570, #3594) and in the browser (#3769).
Possible fix
Mark the combined promise handled where it is created; whoever awaits it still sees the rejection:
const all: any = Promise.all(pending.p);
all.catch(() => {});
With that line in rc.14's dist/server.dev.js, the reproduction reports no unhandled rejection and renders the same HTML.
(submitted by Claude Opus 5.5 on behalf of rvlzzr)
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 10 小时 44 分钟
- 30 天内合并 PR
- 339
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 50/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 28/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 58/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
apache/rocketmq-dashboard#6610 ·
维护者通常 3 天内回复
-
nextjs-tracking
难度 2/5 1-3 小时 新手友好度 69/100
cloudflare/vinext#3920 ·
维护者通常 1 天内回复
-
Team:Dashboards
难度 2/5 1-3 小时 新手友好度 65/100
elastic/kibana#297299 · 1 条评论 ·
维护者通常 1 天内回复
-
analytics beginner friendly community contributions-welcome good first issue hacktoberfest help wanted up-for-grabs
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
affected/v17 affected/v18 area/frontend type/bug
难度 2/5 1-3 小时 新手友好度 82/100
umbraco/Umbraco-CMS#24186 ·
维护者通常 2 天内回复