Repository navigation
fix(signals): a landed transaction stops being the flush's, so a cleanup's action never swallows the next write (#5233) - #5236
Conversation
…nup's action never swallows the next write (solidjs#5233) A cleanup that a landing's commits run can call a synchronous action. Its transaction becomes the flush's, has nothing to wait on, and lands in the same landing loop, while `flushTransaction` still points at it. The next action then merged into the landed transaction: its write showed but was never committed. `land()` now clears `flushTransaction` when it resolves to the transaction being landed, before that landing's commits run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lanes end (solidjs#5233) The reset ran in `land()`, after `endLanesHook` had ended the transaction's lanes. Ending a lane commits its truth over a guess and runs that guess's `equals`; an action started there joined the landed transaction, and its first write committed during its `yield` instead of with its last. The landing loop now clears `flushTransaction` when it resolves to the transaction it is about to land, before the splice, the lanes and the commits. The test adds that case (a guess's `equals` starting an action as the lane ends) beside the cleanup-started control. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ca24d18 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
After #5221, #5225, #5228, #5235 and #5236, until/refresh, compiled base server components, base + router and live + router sat 6-92 B brotli over their caps. Caps move to CI's measure on main @ f7b6b9c + 10 B and recorded minified resets to the measure. No floors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC
…cenarios over their caps (#5241) * fix(release): skip already-published packages in artifact verification Since #4985, h, html and element version on their own, so a core release leaves them at a version already on npm. verify-release-artifacts.mjs dry-run-published every public package, and npm refuses even a dry run over a published version, so the 2.0.1 release failed before publishing anything. It now skips a published version the same way release.mjs does, with packageIsPublished shared from release-packages.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * fix(signals): a reader linked to a settled source no longer stays pending on it retryReaches counted a dep that is the source itself as a path even after that source settled, so settleFamily and the re-park sweep in recompute kept a settled derive node in a reader's pending sources. With an optimistic store over one async memo and a slower sibling memo whose re-ask answers unchanged, the reader stayed pending and the action's transaction never landed. A direct link now counts only while the source is pending. Claude-Session: https://claude.ai/code/session_01CP9T3j2CTCEPyTS2bcKsBu * fix(web): send an empty revalidate declaration as a non-empty header * fix(compiler): treat only a leading comment equal to the static marker as the marker * fix(web): a server function's ReadableStream result stays a ReadableStream The top-level abort wrapper for streamed results matched any async iterable, so a decoded ReadableStream (which is one in Node and Chrome) was replaced by a plain iterable and lost getReader/pipeTo/tee. Leave a ReadableStream out of that check; it passes through as it already does when nested. Test shape from #5175. Co-authored-by: Marve10s <igrimanigroman@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMpyUtA1ZFwzKmr1sg * fix(web): check getReader instead of instanceof ReadableStream The instanceof check with its typeof guard cost +59 B minified on every server-function page and put three page scenarios over their caps. A decoded ReadableStream is told apart from an async generator's result by its getReader method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMpyUtA1ZFwzKmr1sg * fix(web): write the empty revalidate header once; digest it to no keys Send `,` in one header write when the joined keys are only whitespace, and digest `X-Revalidate` with empty keys filtered, so an empty declaration reads as `[]` on the outcome instead of `[""]` or `["", ""]`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * fix(release): wait for the dispatched compiler binary run before watching it The 2.0.4 publish stopped at `gh run watch`: `gh workflow run` printed the new run's URL, and watching it one second later returned 404 because the run was not readable yet. Poll `gh run view` until it resolves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * fix(release): poll the compiler binary run instead of gh run watch The 2.0.4 re-run got past the run lookup, then `gh run watch` failed on the run's jobs (HTTP 404) before GitHub had created them. Poll `gh run view --json status,conclusion` until the run completes, retrying failed reads, and check the conclusion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * fix(signals): a re-parked reader drops a pending source disposed while loading The re-park prune in recompute kept any carried source still flagged STATUS_PENDING, on the assumption that its own settle walk is still to come. A source disposed while loading keeps that flag but never lands, so no walk comes. When a reader parked on an async memo whose owner then re-ran in the same hold, disposing it and creating a replacement that failed, the reader stayed pending on the disposed memo: the hold never landed and its staged error never reached the boundary. A disposed source is now dropped whatever its status, as retryReaches and holdsOn already treat a disposed node as holding nothing (F-3). * chore(size): re-record the six scenarios over their caps on main After the 11-24 fix batch and 2.0.4, six scenarios sat over their brotli caps with 9-14 B of minified allowance left (warnings on main, but the next ~10 B client fix would fail the gate). Caps move to CI's measure on 5420b4a + 10 B and recorded minified resets to the measure. No floors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * chore(signals): pin Sparkplug tiering in the signals bench lane Same flag as the web server lane (#5157). In #5141's fork runs it took the signals lane from one benchmark varying by more than 5% across fresh runners to none, and #4906's omit ownKeys -63% reads 226k vs 235k instructions pinned (673k vs 237k unpinned). Benchmark mode only: the test suite runs in worker threads, which reject V8 flags in execArgv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * chore(size): re-record the three scenarios over their caps on main After #4906, #5209 and #5218, until/refresh, base server components and live server components sat 5-15 B brotli over their caps, so the size gate failed on every PR. Caps move to CI's measure on main @ 50a4bfd + 10 B and recorded minified resets to the measure. The two page scenarios are frozen floors (floor-caps.json). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * test(signals): gate the affects(list) holder test on a promise, not a 20 ms timer The test checked the marks after three settle() ticks while the action waited on a 20 ms timer. On a loaded CI machine the ticks can outlast the timer, so the action landed first and the check saw [false, false, false] (failed on #5230's CI). The action now waits on a gate the test releases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC * chore(size): re-record the four scenarios over their caps on main After #5221, #5225, #5228, #5235 and #5236, until/refresh, compiled base server components, base + router and live + router sat 6-92 B brotli over their caps. Caps move to CI's measure on main @ f7b6b9c + 10 B and recorded minified resets to the measure. No floors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: gnovotny <g.novotny@gmx.ch> Co-authored-by: Marve10s <igrimanigroman@gmail.com> Co-authored-by: gnovotny <990945+gnovotny@users.noreply.github.com>
Summary
Fixes #5233.
When a cleanup (
onCleanup, or a cleanup returned by an effect) runs while a transition lands and calls a synchronous action, the next action's write was shown but never committed. The binding rendered the new value, but the signal still read the old one, so a later write that compared against it was skipped. This is a regression from #5161 (shipped in 2.0.4).After this change, the next action's write commits as it did in 2.0.3.
F T F T TF T F T Funtrack(open)0 1 0 0 00 1 0 1 0Cause
The first Close lands its transaction, and the commits in
land()dispose the branch. The branch's cleanup callsonClose, whose action opens a fresh transaction T3 and joins it (joinFuture): T3 becomesflushTransaction. T3 has nothing to wait on, so the same landing loop insettle()lands it as well, butflushTransactionstill points at it.settle()only reads and clearsflushTransactionbefore that loop, so the pointer survives into the next tick.The next
changeOpen(true)joins its transaction T4. BecauseflushTransactionis T3,joinFuturemerges T4 into T3 and removes T4 fromtransactions. The nextsettle()stagesopeninto T3, which has already landed and is never judged again. The binding shows the staged value, but the write is never committed.Before #5161,
land()ended withif (flushTransaction === u) flushTransaction = null;(added for #4089). #5161 removed it, reasoning that oncejoinFuturerefuses to join a landed transaction, the reset "can no longer trigger". That holds for a write to a node the landing still holds (the #4089 and #5159 cases). It does not hold here: T3 is still live when the flush joins it and only lands afterwards, in a later iteration of the same loop.Fix
The landing loop in
settle()clearsflushTransactionwhen it resolves to the transactionuit is about to land:It runs before
u's lanes end and before its commits, not after the commits as the pre-#5161 line did. Both steps can run user code. The commits run cleanups, and ending a lane commits its truth over a guess and calls that guess'sequals. An action started from either one has to open a transaction of its own instead of merging intou.resolveTxcovers a flush transaction that a guess merged intou.The reset has to come before the lanes end, not only before the commits. If it ran only before the commits (inside
land()), an optimisticequalsthat starts an action as the lane ends would joinu. That action's first write would then commit during itsyield: it reads1while the action waits, where it should stay0until the action ends with2. The newlane teardowntest covers this case.I also tried the other change that makes the repro pass:
liveTx(joined)instead ofresolveTx(joined)insettle(), without the reset. I didn't use it, because it lets the later action's writes commit too early. With an action that writes1, yields, writes2, yields, and writes3, the pairs (rendered, committed) after each step are(1,1) (2,2) (3,3)with that change, against(0,0) (0,0) (3,3)with this one. Each write commits as it is made instead of once when the action ends.Clearing the pointer where a transaction stops being live keeps #5161's scheduler invariant, "a landed transaction holds nothing". Every later join then sees either
nullor a live transaction. An action's writes commit once every body in the hold has returned and the work they put in flight has landed (D-7).#5159 does not come back.
joinFuturekeeps #5161'sliveTxguard, so a write to a node a landed transaction still lists never joins or merges it. This change only adds the reset.cleanup-write-landing-merge-5159.test.ts(3 cases, includingheld-first, which fails before #5161) andcleanup-write-during-landing-4089.test.tspass unchanged.Rules: D-7 (an action's writes commit once every body in the hold has returned and the work they put in flight has landed) and D-9 (holds are formed by the graph, and a hold ends when nothing it waits on is left, so a landed transaction is no hold a later action can join). "A landed transaction holds nothing" is #5161's scheduler invariant, not a rule statement. No rule changed.
RULES-INDEX.mdwas regenerated for the citations.How it was tested
New
packages/signals/tests/cleanup-action-landing-5233.test.ts(7 tests). A memo branch with a cleanup stands in for<Show>with a child, and each test runs Open, Close, Open, Close throughchangeOpen, checking the render anduntrack(open)after each step:onCleanupcalling an empty synchronous action (the issue's repro);async, the control: the cleanup's action awaits before it ends, so it is still live when the landing loop ends;1, yields, and writes2is started while a transaction lands. It must read0while it waits and2at the end. Inregular commitit starts from a cleanup the landing's commits run. Inlane teardownit starts from an optimistic value'sequals, called when the landing ends a lane.On
upstream/main(3448597): 6 failed, 1 passed (async). With the reset insideland(), before the commits but after the lanes end: 6 passed, 1 failed (lane teardown). With this change: 7 passed.I also checked a nested action called from inside the cleanup's action. It passes before and after the fix, so I didn't commit it.
Commands, each with
NODE_OPTIONS=--max-old-space-size=2048and--maxWorkers=3, afterpnpm buildinpackages/signals,packages/solid,packages/webandpackages/universal:packages/signals:vitest runpackages/signals:vitest run tests/cleanup-action-landing-5233.test.ts tests/cleanup-write-landing-merge-5159.test.ts tests/cleanup-write-during-landing-4089.test.ts tests/for-row-cleanup-action.test.tspackages/web:test/for-row-cleanup-action.spec.tsx(#5124's removed-row spec; JSX through the Babel plugin, as the native compiler isn't built here)packages/signals:node scripts/rules-index.mjs --checkpackages/signals:tsc -p tsconfig.build.json(viapnpm build)packages/solid:vitest runprettier --checkon the changed source, test and changesetSize
Measured locally on macOS with
scripts/size(node size.mjs --json head.json --no-gate, thennode gate.mjs head.json base.json) againstupstream/main, rebuildingpackages/signalsfor each side. Minified growth is +22 B on every scenario that includes the scheduler (+23 B on the attribution app and the base page), and 0 B on frames and the two server floors. Brotli moves between −36 B and +49 B from that one change.The gate passes on all 15 scenarios measured, with no cap raised (
check-floor-caps.mjs upstream/main: no cap raised). Two are at their caps:signals: + until/refreshis 8250 B against an 8.25 KB cap, so it has no headroom. Linux CI may measure a few bytes more. If it does, the gate fails there: minified is +22 B over the size recorded with the cap, 2 B past the 20 B allowance. That would need a cap decision.app: hydrating (no stores)is 19145 B against 19.14 KB. It passes with a warning: its minified is 120 B under the size recorded with the cap.The 7 compiled and router scenarios couldn't be bundled locally because the native compiler isn't built here. I expect the same +22 B minified there, and CI will measure them.
Behaviour change
Public API changes
None.
The changeset is
.changeset/cleanup-action-landing-5233.md(@solidjs/signalspatch).🤖 Generated with Claude Code