Skip to content

fix(signals): a lazy memo read only through a rebuilt child memo is not released mid-pass (#4142) - #4164

Merged
ryansolid merged 3 commits into
nextfrom
fix/lazy-memo-loop-4142
Oct 19, 2026
Merged

ryansolid merged 3 commits into
nextfrom
fix/lazy-memo-loop-4142

Conversation

@ryansolid

@ryansolid ryansolid commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #4142, the last open regression gating the next RC (since rc.14).

Before: a lazy async memo read on both sides of a conditional, as in {user() && <User data={user()} />} under <Show>/<Loading>, fetched forever and the boundary never left its fallback.

After: it fetches once and shows its content.

Cause. The compiler turns the condition into a child memo of the hole's pass, and that child memo is the lazy memo's only subscriber. While the fetch is pending the pass never commits, so the next pass tears the old frame's children down on the spot (recompute, CONFIG_STAGED) before it builds its own. That teardown unlinked the lazy memo's last subscriber, and unlinkSubs released it right away. The new condition memo's read then recomputed it from scratch, the fetch went pending again, and the cycle repeated.

How. During that one teardown, last-one-out releases are collected (deferredReleases in graph.ts) instead of run. When the pass ends, recompute releases each one that is still unobserved, reusing releaseIfSettledUnobserved. A lazy node the new pass reads again stays alive. One it stopped reading is still released at the end of the same pass. No public API change.

dormant-memo-chain-3554.test.ts: one expectation changes. In the "made dormant and reawakened while its owner's held children drain" case, lazy1's last reader dies in the same teardown, so lazy1 is no longer made dormant mid-drain and reawakened into the new frame by the cleanup's read. It now dies with the frame it belongs to. The test's point still holds: the drain runs to the end, sibling1 is cleaned, and sibling2 is cleaned on dispose.

Size: +104 B minified on the core floor, about +65 B brotli. Most of it is mangled-name churn from the two new module bindings: the code itself is about 80 B, and I tried three shapes before settling on this one. Hello world (app: compiled floor) stays under 10 KB brotli at 9.86 KB. Caps are raised to measured + 10 B with dated ledger notes, and each recorded minified size is set to the measured value.

Size-Exception: deferring lazy-memo releases until a pending pass ends stops the infinite re-fetch loop in #4142; the maintainer accepted the +104 B minified on 2026-10-19.

How did you test this change?

  • packages/signals/tests/lazy-memo-rebuilt-reader-4142.test.ts:

    • The rebuilt-child-memo case: fails on next (11 runs, nothing shown), passes here.
    • A guard that a lazy memo the rebuilt pass stops reading is still released at the end of that pass.
  • packages/web/test/lazy-memo-loading-loop-4142.spec.tsx: the report's playground, driven through the checkbox's change event. It loops on next and fetches once here.

  • Suites, run locally after turbo build:

    Suite Result
    signals 5368 pass
    web client 1392 pass
    web hydrate 520 pass
    solid 877 pass
    web server 1732 pass; the only failure is the known Node 22 server-functions-adapter-request one

Generated by Claude Code

…ot released mid-pass (#4142)

A pass whose previous pass never committed tears that frame's children
down on the spot, before it builds its own. When a lazy memo's only
subscriber was one of those children (the compiled condition memo of
`user() && <User data={user()} />`), the teardown released it, the new
child's read recomputed it from scratch, the async fetch went pending
again, and the hole looped behind its Loading fallback forever.

The teardown now collects those last-one-out releases and runs them when
the pass ends, so a node the pass reads again stays alive and one it
stopped reading is still released.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0e272be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@solidjs/signals Patch
test-integration Patch
@solidjs/web Patch
@solidjs/babel-plugin Patch
@solidjs/compiler Patch
@solidjs/diagnostics Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
solid-js Patch
@solidjs/universal Patch
board-example Patch
server-dbmon-example Patch
todos-server-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Size (brotli, eager entry chunk)

scenario head vs base minified vs base minified vs recorded cap lazy chunks (not counted)
signals: core floor (createSignal/Memo/Effect/Root/flush) 7.34 KB +53 B (+0.7%) +104 B 0 B 7.35 KB ✅
signals: + createStore 14.88 KB +13 B (+0.1%) +114 B 0 B 14.90 KB ✅
signals: + isPending/latest 10.10 KB +51 B (+0.5%) +106 B 0 B 10.12 KB ✅
signals: + until/refresh (truth readers, no optimism) 7.94 KB +51 B (+0.6%) +103 B 0 B 7.95 KB ✅
app: render + one signal (the simple-app floor) 9.64 KB +34 B (+0.4%) +106 B 0 B 9.66 KB ✅
app: hydrating (no stores) with Show/For/Loading/Errored/lazy 18.27 KB +23 B (+0.1%) +107 B 0 B 18.29 KB ✅ lazy-page.js 0.04 KB
app: hydrating + every store primitive family 30.29 KB +55 B (+0.2%) +114 B 0 B 30.30 KB ✅ lazy-page.js 0.04 KB
app: CSR with Show/For/Loading/Errored/lazy 13.23 KB +7 B (+0.1%) +109 B 0 B 13.24 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier (same app on the observe artifacts) 14.97 KB +45 B (+0.3%) +108 B 0 B 14.99 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier + attribution engine enabled 29.57 KB +72 B (+0.2%) +102 B 0 B 29.59 KB ✅ lazy-page.js 0.04 KB
app: compiled floor (one template, one text hole, one delegated click) 9.85 KB +43 B (+0.4%) +106 B 0 B 9.86 KB ✅
app: compiled CSR (JSX todo app: spread/merge/omit, events, class/style, keyed For, Show, Loading + lazy, store) 26.09 KB +50 B (+0.2%) +103 B 0 B 26.10 KB ✅ stats.js 0.18 KB
app: compiled hydrating (the same JSX todo app through hydrate(), compiled hydratable) 32.11 KB +117 B (+0.4%) +100 B 0 B 32.13 KB ✅ stats.js 0.20 KB
frames: eager client consumer (frames client + transport, lazy codec) 11.75 KB 0 B 0 B 0 B 11.76 KB ✅
page: base server components (hydrating + dynamic + frames + sf reference) 33.15 KB +43 B (+0.1%) +103 B 0 B 33.16 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, trace.js 9.02 KB, wire.js 2.78 KB
page: live server components (base + live/GET + action + isPending/latest) 37.44 KB +83 B (+0.2%) +116 B 0 B 37.46 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.06 KB, trace.js 9.03 KB, wire.js 2.78 KB
page: compiled base server components (the base page as JSX: templates with class/style/attributes/events, For/Show; no spread) 35.17 KB −2 B (−0.0%) +110 B 0 B 35.19 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, regions.js 1.06 KB, sc-comments.js 0.20 KB, trace.js 9.04 KB, wire.js 2.77 KB
page: compiled live server components (the compiled base page + live/GET + action + isPending/latest) 41.29 KB +49 B (+0.1%) +111 B 0 B 41.31 KB ✅ eager (counted): web.js 21.91 KB; assets.js 0.78 KB, decode.js 6.25 KB, regions.js 1.06 KB, sc-comments.js 0.19 KB, trace.js 9.08 KB, wire.js 2.77 KB
page: base + router (base page + @solidjs/router: createRouter, two routes, preload, useNavigate) 40.70 KB +86 B (+0.2%) +104 B 0 B 40.71 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.06 KB, server.js 1.02 KB, serverForms.js 3.59 KB, trace.js 9.13 KB, wire.js 2.77 KB
page: live + router (live page + @solidjs/router: createRouter, two routes, preload, useNavigate) 46.84 KB −22 B (−0.0%) +107 B 0 B 46.86 KB ✅ eager (counted): client.js 27.03 KB; assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, server.js 1.02 KB, serverForms.js 3.30 KB, trace.js 9.06 KB, wire.js 2.80 KB
server: floor (getRequestEvent + isServer) 1.33 KB 0 B 0 B 0 B 1.34 KB ✅
server: renderToString (the server-render floor) 20.62 KB 0 B 0 B −23 B 20.59 KB ⚠️ over by 34 B, 43 B minified headroom

⚠️ Over the brotli cap within the minified allowance (passes)

  • server: renderToString (the server-render floor): over brotli cap by 34 B; minified 72,131 B vs 72,154 B recorded with the cap (−23 B) — 43 B of the 20 B minified allowance left; +0 B minified over this PR's base

Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and its minified size is more than 20 B over the minified recorded with the cap; over the cap within that allowance is brotli layout noise and passes with a warning. Caps and their recorded minified in scripts/size/scenarios.js; the floor and page caps in floor-caps.json are frozen (lower only, or Size-Exception: in the PR body). npm run ratchet lowers caps per RC; it never raises one (scripts/size/README.md).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1
@coveralls

coveralls commented Oct 19, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39339297559

Coverage remained the same at 77.555%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1347
Covered Lines: 1103
Line Coverage: 81.89%
Relevant Branches: 1050
Covered Branches: 756
Branch Coverage: 72.0%
Branches in Coverage %: Yes
Coverage Strength: 27.42 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Member Author

The size gate fails because this fix adds about +104 B minified (~60 B brotli) to every scenario that includes the core, which is over the 20 B allowance. That growth is real, not noise. The caps stay as they are until the maintainer accepts the cost. Then I'll raise them from CI's numbers with ledger notes and add the Size-Exception: line.

— Claude via Claude Code


Generated by Claude Code

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 196 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing fix/lazy-memo-loop-4142 (0e272be) with next (a9b9f9e)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Copy link
Copy Markdown
Member Author

CodSpeed flags mount 4000 rows › memo + sync render effect only (reference) at −10.6%. That benchmark is known to be noisy on this repo: it showed +13.1% on #4159, which doesn't touch this path, and CodSpeed warns that this comparison used a different base commit (667dcff instead of a9b9f9e) and a different runtime environment. Mounting never goes through the teardown path this PR changes, so I'm treating it as noise rather than a regression from this PR.

— Claude via Claude Code


Generated by Claude Code

Accepted by the maintainer on 2026-10-19: +104 B minified on the core floor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants