Backfill in-flight value when latest() companion is created mid-transition - #3042
Open
brenelz wants to merge 1 commit into
Open
Backfill in-flight value when latest() companion is created mid-transition#3042brenelz wants to merge 1 commit into
brenelz wants to merge 1 commit into
Conversation
…ition (solidjs#3041) getLatestValueComputed created the latest-value companion with no backfill, so a latest() first read during a held transition (e.g. a pending banner gated on isPending()) saw the committed value instead of the pending write. syncCompanions only updates companions that already exist at write time. Mirror getPendingSignal and seed the companion from _pendingValue on creation. Fixes solidjs#3041 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 9efb10d The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 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.
Fixes #3041
Problem
latest(() => query())first called during a held transition returned the committed value instead of the in-flight one. The reporter's case: a "Now loading: {latest(query)}" banner gated onisPending()showed the previous pokemon's name.getLatestValueComputedcreates the latest-value companion lazily withoptimisticComputed(() => read(el))and no backfill. Under an optimistic lane with a stale (render-effect) reader,read(el)resolves to_value, so the companion captures the committed value.syncCompanionsonly pushes a pending write into companions that already exist at write time — so a companion born after the write never learns it.getPendingSignalalready backfills on creation, which is whyisPending()was correct on first use whilelatest()wasn't.Fix
Seed the companion from
_pendingValueon creation (guarded by!hasActiveOverride, since overrides are already authoritative throughread()'s A17 path), mirroringgetPendingSignal.Test
latest-lazy-companion-backfill.test.ts— lazy-creation case (failed before, passes now) plus a pre-warmed control. Full solid-signals suite green (1336 tests).🤖 Generated with Claude Code