Conversation
…s#3726) A derived store whose first run returned a pending promise and whose rerun landed synchronously kept STATUS_UNINITIALIZED on the projection computed until the flush commit, because recompute only clears the flag on a creation pass. The recompute-side settle walk (solidjs#3181) requires the node to be initialized, so it skipped the projection, and readers subscribed to a store node the landing left unchanged (`"length" in store` on an array seed, `Object.keys`, an unchanged `length`) had no value notification to fall back on. They stayed pending, blank inside a loading boundary, while a sibling read of the source updated. The projection's sync commit through the setter now retires the flag the way asyncWrite does after its setter landing, so the walk releases those readers in the same flush. The retirement is gated on the previous run having been pending, which leaves a born-held creation pass unchanged.
The projection computed retires STATUS_UNINITIALIZED after a synchronous landing only when the pass is mainline or its transaction is parked by nothing but the node's own flight, so a landing staged by a live action or beside another pending source keeps the seed invisible until that transaction commits. The gate is keyed on the node's own pending-source entry instead of any STATUS_PENDING, so a first run parked on an upstream async source no longer trips it. The tests assert in the flush that lands the sync value, register a length reader, and pin the transaction-held case.
🦋 Changeset detectedLatest commit: 37ac480 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 performance
Comparing Footnotes
|
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.
Fixes #3726
What was broken
A derived
createStorewhose first run returned a pending promise, and whose rerun after a source write returned a value synchronously, left some readers pending forever. A reader whose store node the landing did not change ("length" in store,Object.keys, an unchangedlength) rendered blank inside ``, while a sibling read of the source updated.Root cause
The projection computed kept
STATUS_UNINITIALIZEDuntil the flush commit, becauserecomputeclears it only on a creation pass. The settle walk that releases readers parked on a superseded flight skips uninitialized nodes, and unchanged-node readers get no value notification to fall back on.Change
After the synchronous commit,
runProjectionComputedNextclearsSTATUS_UNINITIALIZEDwhen the node's own flight was pending and no transaction holds the landing, the same way the async landing path does after its setter commit. A landing held by a transaction (a live action, a blocked transition, or another pending source) keeps the flag, so the seed stays invisible until that transaction commits.Verification
cd packages/signals && npx vitest run tests/store/derived-presence-async-3726.test.ts: 3 passed. Two of the cases fail onnextwithout the fix.packages/signals: 4794 passed.packages/solid: 817 passed.packages/web: default, hydrate and server suites pass, except one server spec that also fails onnext.Open
recompute, which would cover every computed type.nexttoo.