rc.9: deferred child recomputation loses REACTIVE_ZOMBIE and leaks subscriptions
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- frontend, performance
调研方向
先从链接的 playground 复现开始,然后检查 @solidjs/signals/dist/dev-shared.js 中 recompute、updateIfNecessary 和 disposeChildren 附近的代码,尤其是三个 flag 重置以及 REACTIVE_ZOMBIE 的处理。使用 40-update control 和 DEV.getObservers 验证,交替更新 signals 会在 action 处于 pending 状态期间以及完成之后都保持两个 subscribers。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
An unrelated pending action causes subscriptions from a Show condition to accumulate across ordinary signal updates. They remain after the action finishes.
The reduced case uses two ordinary signals, one action, a sibling binding reading the action-written signal, and:
<Show when={n() > 0 && n() < 2}>Visible</Show>
No optimistic store, router, SSR, effects, or application-managed ownership is involved. The compiler creates a nested memo in the condition getter. Repeatedly alternating n between 0 and 1 should keep the graph bounded.
Your Example Website or App
https://s.olid.uk/?id=9ec31682-7443-42c7-b68e-4020eef4d836
Steps to Reproduce the Bug or Issue
Open the linked playground and click Run reproduction once. It runs a 40-update control, starts an action waiting on a promise, and alternates the other signal until Solid emits its real HUGE_FAN_OUT warning (at most 4,200 updates). It then releases and awaits the action.
Each write is followed by public flush(); the loop yields to the browser every 100 updates. Counts use DEV.getObservers, and the warning is captured through OBSERVE.diagnostics.
Observed with published rc.9:
- No pending action: 2 subscribers after 40 updates.
- Pending action: 2,000 subscribers after 3,997 updates, triggering
HUGE_FAN_OUT. - After the action finishes: still 2,000 subscribers.
Expected behavior
Obsolete computations should be disposed. Repeating the same two signal values should keep the subscriber count bounded, including while an unrelated action is pending and after it finishes.
Screenshots or Videos
No response
Platform
- Solid packages: 2.0.0-rc.9
- Development DOM build; published native compiler, generate: "dom", dev: true
- Chromium on Linux/WSL
Additional context
Runtime trace and causal check
In @solidjs/signals/dist/dev-shared.js from rc.9:
- The previous child is marked
REACTIVE_ZOMBIEand moved to its owner's_pendingFirstChild; its replacement occupies_firstChild. - While an action is parked, an ambient update can rerun the deferred child via
zombieQueue. recomputedropsREACTIVE_ZOMBIEin its flag resets (lines 4272 and 4437);updateIfNecessaryalso drops it in its final mask (line 4802).disposeChildren(child, true)relies on this flag to skip the ordinary parent-chain splice (around lines 2730–2741). With the flag lost, disposing the old child writesparent._firstChild = nullin this single-child case, detaching the replacement.- The replacement remains subscribed, but future owner cleanup cannot reach it.
An instrumented six-update trace showed the deferred child entering recomputation with flags 42 (including zombie 32), reaching disposal with flags 0, and erasing the current child. The orphaned replacement continued recomputing on subsequent updates.
As a causal experiment, preserving REACTIVE_ZOMBIE through those three flag resets in an isolated, in-memory test bundle keeps the count at 2 subscribers after all 4,200 updates and after action completion, with no warning. This is not a proposed fully validated fix; broader transition/ownership regression coverage is still needed.
Originally noticed as increasing CPU stalls while dragging cards with saves in flight. The app had retained compiler memos under Show condition owners matching this mechanism. The reduced case isolates the leak; it does not claim to quantify the full app's per-gesture amplification.
- 主要语言
- TypeScript
- 星标
- 36.2k
- 派生
- 1.1k
- 平均合并
- 11 小时 19 分钟
- 30 天内合并 PR
- 337
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14可能已有人在做 @itisrmk 于 8 天前认领。 未关闭1.x
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 57/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list items可能已有人在做 @boombang 于 10 天前认领。 未关闭1.x
难度 4/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
type: bug
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
0️⃣ phase/new
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 70/100
microsoft/playwright#43640 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100