Skip to content

Backfill in-flight value when latest() companion is created mid-transition - #3042

Open
brenelz wants to merge 1 commit into
solidjs:nextfrom
brenelz:fix/latest-lazy-companion-backfill
Open

Backfill in-flight value when latest() companion is created mid-transition#3042
brenelz wants to merge 1 commit into
solidjs:nextfrom
brenelz:fix/latest-lazy-companion-backfill

Conversation

@brenelz

@brenelz brenelz commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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 on isPending() showed the previous pokemon's name.

getLatestValueComputed creates the latest-value companion lazily with optimisticComputed(() => 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. syncCompanions only pushes a pending write into companions that already exist at write time — so a companion born after the write never learns it. getPendingSignal already backfills on creation, which is why isPending() was correct on first use while latest() wasn't.

Fix

Seed the companion from _pendingValue on creation (guarded by !hasActiveOverride, since overrides are already authoritative through read()'s A17 path), mirroring getPendingSignal.

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

…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-bot

changeset-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9efb10d

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

This PR includes changesets to release 9 packages
Name Type
@solidjs/signals Patch
test-integration Patch
solid-js Patch
babel-preset-solid Patch
@solidjs/web Patch
@solidjs/html Patch
@solidjs/h Patch
@solidjs/universal Patch
@solidjs/element 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

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.

1 participant