[2.0.0-rc.13] SSR stream never ends: after a hole retry re-creates a component, a cascading memo spins in microtasks on a shared serialization slot
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- backend, performance
调研方向
Start by reading solid-js/dist/server.js, especially processResult (around lines 717–827), subscribePendingRetry (around line 425), and the server createMemo update path; the reproduction gives a way to trigger the issue. Check how a retry handles a memo whose shared serialization slot has already resolved. Done means the reproduction’s stream completes with the expected markup and serialized data, without a microtask loop.
由索引模型根据 Issue 内容生成。
描述
[2.0.0-rc.13] SSR stream never ends: after a hole retry re-creates a component, a cascading memo spins in microtasks on a shared serialization slot
Summary
With renderToStream, a function hole that creates a component ({() => <Page />}) becomes the retry unit when what the component returns, the output of a lazy() component, is still pending. The retry runs the hole again, so Page is set up a second time, under the same owner ids. The second user memo is created while the first one's serialization slot is still pending, and it takes over that slot's deferred (const deferred = slot ? slot.d : createDeferredPromise(), solid-js/dist/server.js:743). It waits on its own promise but throws NotReadyError(slot.d.promise) (:827). When the first user resolves the slot, the second info memo (which reads user()) retries through subscribePendingRetry. It reads user() again and gets the same, already-resolved promise, so it retries again in the next microtask, and this never stops. The microtask queue never drains, so no timer fires: not the second user's own setTimeout (the only thing that could end the loop), and not any other timer in the process. The stream writes nothing and never ends, and the Node process sits at 100% CPU. We found it in a library that compiles to this shape (a component call inside a hole). Handwritten Solid in the same shape loops the same way, as the reproduction below shows.
Reproduction (plain Solid, no other libraries)
repro.jsx, compiled for SSR (@solidjs/compiler transform(src, { generate: "ssr", hydratable: true }), or vite-plugin-solid with ssr: true), then run with node:
import { createMemo, lazy } from "solid-js";
import { renderToStream } from "@solidjs/web";
const delay = (value, ms) => new Promise(r => setTimeout(() => r(value), ms));
// a lazy component: pending until its "chunk" loads
const Profile = lazy(() => delay({ default: props => <h1>{props.user.name}</h1> }, 10));
let setups = 0, infoRuns = 0;
function Page() {
console.log(`Page set up (${++setups})`);
const user = createMemo(() => delay({ name: "Jon" }, 50));
const info = createMemo(() => {
if (++infoRuns % 1e6 === 0) console.log(`info memo ran ${infoRuns} times`);
user(); // cascading load, as in examples/rendering's /profile
return delay(["a", "b"], 50);
});
return <Profile user={user()} info={info()} />;
}
const t0 = Date.now();
setTimeout(() => console.log("200 ms timer fired"), 200); // never fires
renderToStream(() => <main>{() => <Page />}</main>, { manifest: {} }).pipe({
write: html => console.log("html:", html),
end: () => console.log(`ended after ${Date.now() - t0} ms; Page set up ${setups}x`)
});
({ manifest: {} } is only there because the server lazy() throws "no asset manifest is set" without one.)
Output (killed by a 20 s alarm; production and --conditions=development builds behave the same):
Page set up (1)
Page set up (2)
info memo ran 1000000 times
info memo ran 2000000 times
…
info memo ran 29000000 times
<killed after 20 s: no "html:" chunk, no "ended", the 200 ms timer never fired>
What each part does (each variant checked with the same script):
| Change | Result |
|---|---|
<main><Page /></main> (component created at template time, not inside a function hole) |
Ends in ~105 ms. Page set up 1×, correct markup and serialized data. |
<main>{() => [<Page />]}</main> (same hole, but the result is wrapped in an array) |
Ends in ~106 ms. Page set up 1×. |
No info memo (only user) |
Page is still set up 2×, but the render ends (~73 ms). The double setup happens either way; the cascading memo turns it into the hang. |
No lazy() (Profile a plain component) |
Page set up 1×. Ends. |
ProfileView with a <Loading> whose <For each={props.info}> reads info |
The <Loading>'s discovery spins too, and after 10,001 passes it throws <Loading> boundary discovery did not converge after 10001 passes …. That disposes the render, which also stops the memo loop. The stream then ends after ~96 ms without writing any chunk. (The unbudgeted memo loop above is the hang; the budget only hides it when a <Loading> happens to read the same source.) |
renderToString |
Not affected: it throws "This value cannot be rendered synchronously. Are you missing a boundary?" before any retry. |
What was verified. All of the above was run on macOS (arm64, Darwin 25.5.0) against the installed rc.13 packages, with each run under a 20 s alarm: production server builds, and the hang again with --conditions=development. The diagnosis (the second memo reuses the slot deferred, NotReadyError names that deferred, the retry goes through subscribePendingRetry) comes from reading solid-js/dist/server.js (processResult lines 717–827, subscribePendingRetry at 425, the server createMemo update()), and it matches the counters. Not verified: I did not instrument the owner ids to prove the second user gets the same id as the first (inferred from the slot lookup by ownerId(owner) succeeding). I did not test with Vite's SSR loader in this exact repro (the original finding was under vite dev). I did not test on any version other than rc.13, or check whether main has already changed this path.
Expected vs actual
Expected: the stream ends after both async memos settle (about 100 ms), with <main _hk=0><h1 _hk=30>Jon</h1></main> and the serialized user and info data, the same as when <Page /> is created at template time. Ideally Page is also set up only once. Even if a retry re-creates it, the second set of memos should either get their own slots or settle from the first set's values. They should never retry on a promise that has already resolved.
Actual: Page is set up twice. The second info memo re-runs tens of millions of times in microtasks (about 1.5 M/s here). No setTimeout callback ever runs again in the process, no chunk is written, and the stream never ends. Nothing is logged and no error is thrown. The only visible signs are a stuck request and a busy CPU.
Versions
solid-js2.0.0-rc.13@solidjs/web2.0.0-rc.13@solidjs/compiler2.0.0-rc.13 (used to compile the repro for SSR)- Node v24.18.0, macOS (Darwin 25.5.0, arm64)
Workaround (solid-blocks, commit 046387b)
On the server, solid-blocks' perform (packages/blocks/src/runtime.ts) now returns a view that is a function (a flow control's or a lazy component's output) wrapped in a one-element array ([view]) instead of returning it bare into the hole. Solid's server renderer then resolves and retries that function as its own node, so the hole that created the component is not re-run. The page is set up once and the shared-slot loop is never reached. The workaround avoids the trigger and leaves the Solid bug in place. In handwritten code the same move, {() => [<Page />]}, or creating the component at template time, avoids it too (both verified above).
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 11 小时 25 分钟
- 30 天内合并 PR
- 345
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
维护者通常 1 天内回复
-
Select loses its bound value when options load asynchronously可能已有人在做 @MokiMeow 今天认领。 未关闭
难度 3/5 半天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 18/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 24/100
维护者通常 1 天内回复
相似的 Issue
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked files未关闭
难度 2/5 1-3 小时 新手友好度 70/100
maniator/verticopolis#880 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 62/100
siyuan-note/siyuan#20353 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
black-forest-labs/skills#17 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
Albert-Weasker/niubigeo#168 ·
维护者通常 1 天内回复