Repository navigation
fix(fetchium): stop subscriptions leaking after a query deactivates mid-fetch - #66
Merged
Merged
Conversation
…id-fetch An aborted fetch's runQuery finally called reconcileSubscription after deactivate() had cleared lastSubscribeFn, starting a new subscription on the inactive query that nothing unsubscribed, even after eviction. reconcileSubscription now bails when the query is inactive, and handleEviction stops any subscription still running. Fixes COR2-1569 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jimmy-phantom
approved these changes
Sep 29, 2026
3 tasks done
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 COR2-1569.
Problem
If a query deactivated while a fetch was in flight,
deactivate()stopped the subscription and clearedlastSubscribeFn. The aborted fetch'srunQueryfinallythen calledreconcileSubscription(), which sawundefined !== subscribeFnand started a new subscription on the inactive query. Nothing ever unsubscribed it, not even eviction. Each navigation added morepoll()loops that refetched from instances that had already been evicted.Fix
reconcileSubscription()returns early when the query isn't active. Every legitimate call (first load, reactivation, a params change, a fetch that wasn't aborted) happens while the query is active.handleEvictionstops any subscription still running before it deletes the instance, as a backstop. The unsubscribe code moved into a newQueryInstance.stopSubscription(), whichdeactivate()also uses.Tests
Two new cases in
poll.test.ts: one deactivates during the initial fetch, the other during a poll refetch. Before the fix they failed with extra fetches after unmount (3 instead of 1, and 4 instead of 2).Tested on this branch and on top of the reverted tree (the hotfix release state): the unit and React suites pass and
check-typesis clean.This PR doesn't depend on the revert PR. Both need to merge before the Version Packages PR (#63).
🤖 Generated with Claude Code