[2.0 rc.20 / next] A value that fails to serialize stays pending on the client while the render reports completion
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- backend
调研方向
Start with the default serializer's onError in packages/web/src/server.ts (around L2532), where a serialization failure is only reported. Run the included repro.mjs to see completedAll: true with the key left pending. Done means either the render fails like a rejection, or the key is settled as a rejection that <Errored> can catch, and onCompleteAll no longer fires while a key is unsettled. The choice between those two behaviours is a design decision for maintainers, so confirm it before writing code.
由索引模型根据 Issue 内容生成。
描述
In #4242, the value that fails to serialize was noted as still not resolving, as a separate problem. This is that problem on its own, since I couldn't find an issue for it.
When the default serializer cannot serialize a resolved async value, the error reaches the error hook with handling: "serialize", the render completes and onCompleteAll runs. The hydration payload declares the promise for that key but never settles it, so the client waits for it forever: nothing hydrates past it, and there is no rejection for an <Errored> to catch.
A rejected async value in the same spot fails the render instead: the promise form resolves with no HTML and onCompleteAll is not called. So the server reports a broken document as a successful one only in the serialization case.
Versions
solid-js and @solidjs/web 2.0.0-rc.20 from npm, and next at ab29345. Node 26.13.0.
Reproduction
Save as repro.mjs in a project with solid-js and @solidjs/web 2.0.0-rc.20, then run node repro.mjs:
import { renderToStream, ssr, escape } from "@solidjs/web";
import { createMemo } from "solid-js";
class Unserializable {}
function App() {
const value = createMemo(() => Promise.resolve(new Unserializable()));
return ssr(["<main>", "</main>"], () => escape(String(value() instanceof Unserializable)));
}
let completedAll = false;
const errors = [];
const html = await renderToStream(App, {
onCompleteAll: () => (completedAll = true),
onError: error => errors.push(error?.constructor?.name)
});
console.log(html);
console.log({ completedAll, errors });
Observed
<main>true</main><script>(self.$R=self.$R||{})[""]=[];_$HY.r["0"]=$R[0]=($R[1]=($R[2]=() => {
const resolver = {
p: 0,
s: 0,
f: 0
};
resolver.p = new Promise((resolve, reject) => {
resolver.s = resolve;
resolver.f = reject;
});
return resolver;
})()).p;</script>
{ completedAll: true, errors: [ 'SerovalUnsupportedTypeError' ] }
$R[1] is never settled. With a serializable value, the payload ends with the call that resolves it (($R[3]=(resolver, data) => {...})($R[1],"loaded")). With Promise.reject(new Error("...")) instead, the output is an empty document and { completedAll: false, errors: [ 'Error' ] }.
Expected
A value that cannot be serialized is handled like a failure of that value: either the render fails the same way it does for a rejection, or the key reaches the client as a rejection that the nearest <Errored> can handle. In both cases onCompleteAll should not report the document as complete while one of its keys can never settle.
Cause
The default serializer's onError only reports the failure (packages/web/src/server.ts, L2532 on next). Nothing fails the render or writes a settle call for the key, and the render then completes through the normal path.
- 主要语言
- TypeScript
- 星标
- 36.2k
- 派生
- 1.1k
- 平均合并
- 10 小时 39 分钟
- 30 天内合并 PR
- 500
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
[2.0 / next] Optimistic todo list with an "N left" memo loops forever when a toggle's save lands未关闭
难度 5/5 一周以上 新手友好度 15/100
维护者通常 1 天内回复
-
[2.0 / next] createOptimisticStore: add, delete, add with saves pending hands <For> an undefined row未关闭
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 18/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
pingdotgg/t3code#30228 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
难度 2/5 1-3 小时 新手友好度 66/100
vfarcic/dot-agent-deck#2079 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 1 天内回复