Repository navigation
fix(fetchium): refetch active queries on invalidateQueries - #17
Merged
Merged
Conversation
`queryClient.invalidateQueries(...)` previously only set `updatedAt = 0` via `markStale()`, which left mounted consumers showing stale data until they remounted — invalidation was effectively a no-op for the active case. Other reactive query libraries (React Query, SWR) refetch active observers on invalidate; align with that contract. `markStale()` now kicks a debounced refetch when the relay is currently active (tracked via a new `_isActive` flag set by the relay's update/deactivate hooks). Inactive relays are unchanged: `updatedAt = 0` plus the existing stale-on-activate path picks up the refetch on next mount. `runDebounced()` already bails when a fetch is in flight, so overlapping invalidations dedupe. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks done
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pzuraq
approved these changes
May 5, 2026
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.
Summary
queryClient.invalidateQueries(...)previously only setupdatedAt = 0viamarkStale(), leaving currently-mounted consumers showing stale data until they remounted. Other reactive query libraries (React Query, SWR) refetch any query that has active observers on invalidate; this aligns with that contract.markStale()now kicks a debounced refetch when the relay is currently active (tracked via a new_isActiveflag set by the relay's update/deactivate hooks). Inactive relays keep their existing behavior:updatedAt = 0plus the stale-on-activate path picks up the refetch on the next mount.runDebounced()already bails when a fetch is in flight, so overlapping invalidations dedupe.Test plan
invalidate-queries.test.ts: active-query refetch, unmounted-no-refetch, params filter, dedupenpm run test:unit(1133 passed)npm run check-typesnpm run lint🤖 Generated with Claude Code