Skip to content

fix: lazily create inTransition external source to prevent use-after-dispose#2589

Open
veeceey wants to merge 2 commits intosolidjs:mainfrom
veeceey:fix/issue-2275-external-source-transition
Open

fix: lazily create inTransition external source to prevent use-after-dispose#2589
veeceey wants to merge 2 commits intosolidjs:mainfrom
veeceey:fix/issue-2275-external-source-transition

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 15, 2026

Fixes #2275

Problem

When using enableExternalSource with transitions and a suspense context, the inTransition external source is created eagerly during computation setup and disposed after the transition promise resolves. If a subsequent transition starts later, the code tries to call .track() on the already-disposed inTransition instance, which throws an error.

The reporter's workaround was to ignore dispose() calls for inTransition computations, which leaks memory.

Fix

Instead of eagerly creating inTransition upfront and holding a single reference forever, this change:

  1. Starts with inTransition as undefined
  2. Lazily creates it on the first access during a running transition
  3. After a transition resolves, disposes and sets it back to undefined
  4. On the next transition, a fresh instance is created automatically

This matches the approach suggested by @milomg in the issue comments. The key insight is that the inTransition source only needs to exist while a transition is actively running - there's no reason to keep a stale/disposed instance around between transitions.

Test

Added a test that sets up an external source with a suspense context, runs two sequential transitions, and verifies the second transition doesn't throw due to the disposed inTransition source.

…dispose

The inTransition external source was eagerly created and disposed after
each transition resolved. When a subsequent transition started, the
disposed source was still referenced, causing errors when .track() was
called on it.

This change makes inTransition lazily initialized on first use during a
transition and properly re-created after disposal. Fixes solidjs#2275.
@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2026

🦋 Changeset detected

Latest commit: 1660690

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

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration 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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

External source will rerun disposed inTransition computation function if there is a suspense context

1 participant

Comments