fix: re-subscribe to ordinary external source after a transition - #2992
Open
SnowingFox wants to merge 1 commit into
Open
fix: re-subscribe to ordinary external source after a transition#2992SnowingFox wants to merge 1 commit into
SnowingFox wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 619e252 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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.
Problem
A computation created while a
startTransitionis pending never receives more than one external update whenenableExternalSourceis enabled. In an app this shows up as a subtree that renders correctly, updates once, then stays stale until something else forces it to re-run.Root cause
When
ExternalSourceConfigis set,createComputation(inpackages/solid/src/reactive/signal.ts) wraps the computation's fn so that a run while a transition is pending tracks the computation on a transition-scoped external source (inTransition) instead of the ordinary one. A computation created during a transition only ever hasinTransition.track()called, so its ordinary source records zero dependencies. After the transition completes,triggerInTransition's.then()disposes the transition-scoped source and nothing ever re-registers the computation on the ordinary source — the external system can no longer invalidate it.Fix
Track whether the computation has ever run through the ordinary external source. When the transition-scoped source is disposed, if it never did, fire the computation's trigger once so it re-runs through the ordinary source and re-subscribes. If the computation was disposed in the meantime the trigger is a no-op, because the computation is no longer an observer of the internal
tracksignal.Test
Adds a regression test to
packages/solid/test/external-source.spec.tsthat creates a memo inside a transition, applies two external updates, and asserts both are delivered. Onmainthe second update is lost and the test fails.Fixes #2953