Skip to content

fix(fetchium): stop subscriptions leaking after a query deactivates mid-fetch - #66

Merged
abedell-phantom merged 1 commit into
mainfrom
fix/cor2-1569-on-main
Sep 29, 2026
Merged

abedell-phantom merged 1 commit into
mainfrom
fix/cor2-1569-on-main

Conversation

@abedell-phantom

Copy link
Copy Markdown
Contributor

Fixes COR2-1569.

Problem

If a query deactivated while a fetch was in flight, deactivate() stopped the subscription and cleared lastSubscribeFn. The aborted fetch's runQuery finally then called reconcileSubscription(), which saw undefined !== subscribeFn and started a new subscription on the inactive query. Nothing ever unsubscribed it, not even eviction. Each navigation added more poll() 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.
  • handleEviction stops any subscription still running before it deletes the instance, as a backstop. The unsubscribe code moved into a new QueryInstance.stopSubscription(), which deactivate() 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-types is clean.

This PR doesn't depend on the revert PR. Both need to merge before the Version Packages PR (#63).

🤖 Generated with Claude Code

…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>
@abedell-phantom
abedell-phantom requested review from a team and pzuraq as code owners September 29, 2026 21:52
@abedell-phantom
abedell-phantom merged commit 227d73d into main Sep 29, 2026
1 check passed
@abedell-phantom
abedell-phantom deleted the fix/cor2-1569-on-main branch September 29, 2026 21:58
@abedell-phantom abedell-phantom mentioned this pull request Sep 29, 2026
3 tasks done
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.

2 participants