Repository navigation
Conversation
…'s hold (solidjs#5344) Problem: When an action B calls efresh(o) on a createOptimistic value that already carries another action A's guess, the refresh answer showed immediately as soon as it landed after A ended — while B was still open — violating D-31 ("Called inside a hold, the landing is staged into that hold") and D-33 ("A change that would alter what a guess sits on merges with that guess's hold..."). When the refresh started before the guess, �pplyGuesses() merged the two holds and kept the guess on screen until B ended. Root cause: - In packages/signals/src/core/async.ts ( otifyStatus), a guessed node going pending on REACTIVE_REASK called joinFuture(null) instead of joining the guess's parent transaction, leaving action B's transaction unmerged with A's. - In packages/signals/src/core/scheduler.ts (GlobalQueue.settle), the pendingNodes loop skipped nodes with CONFIG_OVERRIDE (including CONFIG_GUESS), so o was never associated with B's transaction , leaving ._nodes empty and disconnected from A's lane parent. When A ended and the refresh landed, supersede() staged the answer into A's transaction, which was no longer blocked (_open === 0) and committed immediately while B was still open. - For synchronous createOptimistic recomputes, laneOutcome() in packages/signals/src/core/guesses.ts superseded directly into A's parent without merging with lushTransaction. Fix: - packages/signals/src/core/async.ts: on a CONFIG_GUESS node going pending, do not open a spurious transaction for REACTIVE_REASK (if (passLane === null && !(el._flags & REACTIVE_REASK)) joinFuture(txOf(el)._parent)). - packages/signals/src/core/scheduler.ts: in GlobalQueue.settle(), when parking into a hold ( !== null), merge xOf(n)._parent! into for any CONFIG_GUESS node queued in pendingNodes (gated on guessing so non-optimistic bundles fold it away). - packages/signals/src/core/guesses.ts: in laneOutcome(), join xOf(el)._parent when lushTransaction !== null so synchronous refreshes inside a hold merge symmetrically. - Added regression tests in packages/signals/tests/action-refresh-hold-after-guess-5344.test.ts, updated packages/signals/docs/RULES-INDEX.md, and added a patch changeset. Verification: - Mutation proof: reverting the 3 source files caused 7/15 tests in �ction-refresh-hold-after-guess-5344.test.ts to fail; restoring passed 15/15. - @solidjs/signals build + sc -p tsconfig.build.json + test suite (577 functional test files passed; only 3 pre-existing Windows-only harness files failed on ENAMETOOLONG / CRLF / path separators; Linux-equivalent ules-index.mjs --check passed). - packages/solid build + types + test-types + tests (59/61 passed; 2 pre-existing Windows-only harness files). - prettier --check and ode scripts/check-release-invariants.mjs passed.
🦋 Changeset detectedLatest commit: 6dce579 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5344.
Problem
When action A places an optimistic guess on an async or sync
createOptimisticsignalobefore action B callsrefresh(o)(guess-first), ending A allows the refresh's landed value to commit immediately while B is still open. Inrefresh-firstorder, the screen keeps the guess until B ends (matchingRULES-DERIVED.mdD-31 & D-33). In addition,yield refresh(o)inside B hung waiting on A's hold while A remained open.Root Cause
refresh-first, B'srefresh(o)parkedointxB(CONFIG_HELD), so A's subsequentapplyGuesses()sawCONFIG_HELD, created the guess lane undertxB, and mergedtxAandtxB.guess-first,owas already in A's guess lane (CONFIG_OVERRIDE | CONFIG_GUESS) undertxA. When B calledrefresh(o):notifyStatus()(packages/signals/src/core/async.ts) ranjoinFuture(null)onREACTIVE_REASK, which was a no-op whenflushTransactionwas alreadytxB(and otherwise opened a spurious transaction on bare outside-actionrefresh(o)).GlobalQueue.settle()(packages/signals/src/core/scheduler.ts) skipped allCONFIG_OVERRIDEnodes inpendingNodes, leavingtxBcompletely disconnected fromoandtxA. When A ended,supersede()staged the landed refresh value intotxA, whose_opencount had reached0, committing immediately while B was still open.createOptimisticrecomputations,laneOutcome()(packages/signals/src/core/guesses.ts) superseded intotxAwithout merging the activeflushTransaction.Fix
packages/signals/src/core/async.ts: onCONFIG_GUESSenteringSTATUS_PENDING, skipjoinFuturewhenREACTIVE_REASKis set so bare outsiderefresh(o)does not open a spurious transaction, leaving hold merging tosettle().packages/signals/src/core/scheduler.ts: inGlobalQueue.settle(), when parking into a real holdt, mergetxOf(n)._parentwithtfor anyCONFIG_GUESSnode inpendingNodes(gated onguessingso non-optimistic bundles tree-shake it away).packages/signals/src/core/guesses.ts: inlaneOutcome(), calljoinFuture(txOf(el)._parent)whenflushTransaction !== nullso synchronouscreateOptimisticrefreshes inside a hold merge with the guess's hold.packages/signals/docs/RULES-INDEX.mdcitations for D-31 / D-33 and added.changeset/action-refresh-hold-after-guess-5344.md.How did you test this change?
packages/signals/tests/action-refresh-hold-after-guess-5344.test.tscovering bothguess-firstandrefresh-firstorders across:yield refresh(o)inside B delivering the staged value while screen keeps the guess (D-31)createOptimisticrefresh inside B staying held after A endsrefresh(o)control (no spurious hold on sibling sync writes)A -> B -> C) and same-tick non-action holdsrc/core/{async,guesses,scheduler}.tsreverted toupstream/main:pnpm --filter @solidjs/signals exec vitest run tests/action-refresh-hold-after-guess-5344.test.ts-> 7 failed | 8 passed (15) (all 7guess-first/ chained / non-action hold cases reproduce the leak).pnpm --filter @solidjs/signals build(rollup + mangle-props + check-pure +tsc -p tsconfig.build.json) -> passed, 0 errors/warnings in changed files.pnpm --filter @solidjs/signals exec vitest run tests/action-refresh-hold-after-guess-5344.test.ts-> 15 passed (15).123functional test files inpackages/signals) -> 1,924 passed, 0 failed; fullpackages/signals(577non-Windows-path-harness files) andpackages/solid(59non-Windows-harness files,945tests) passed.pnpm --filter ./packages/solid test-types-> passed.node scripts/rules-index.mjs --check(LF + POSIX path verified) ->every src/ citation resolves (110 ids); docs/RULES-INDEX.md is current.pnpm exec prettier --checkon all authored/edited code & changeset files -> passed.node scripts/check-release-invariants.mjs-> passed.