React suspense cache poisoning - #3898
Merged
JoviDeCroock merged 2 commits intoJul 10, 2026
Merged
Conversation
Two failing tests for the react bindings' per-client suspense cache: 1. When a teardown operation is dispatched while a useQuery is suspended (another consumer unmounting or re-executing, an exchange cancelling in-flight operations), the operation's result source ends without a result. The suspense promise never resolves, stays in the cache, and is re-thrown on every future render, so the component never leaves its Suspense fallback again. 2. When a suspense cache entry is (or becomes) an already-settled promise, useQuery re-throws it on every render. React re-attaches a ping listener each attempt, which fires immediately for a settled thenable: an unbounded render loop that freezes the tab. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 82f88cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
JoviDeCroock
approved these changes
Jul 10, 2026
This was referenced Jul 10, 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
The suspense cache in
useQuerycan end up holding a promise that nothing will ever replace, and then throws that same promise on every render.There were two ways to get in this state:
Such entries are now evicted from the suspense cache and the query is executed again.
Set of changes
Only
packages/react-urql. Nothing breaking, these were states you couldn't get out of before.src/hooks/useQuery.ts: anonEndon the result source that evicts the entry and resolves the promise if the source ended without a result, plus a settle handler on cached thenables that evicts them once they settle. In both cases the entry has lost the subscription that would have replaced it, so the next render has to start over.src/hooks/useQuery.suspense.spec.tsx: one test per scenario. Both fail onmain: the first hangs on the fallback, the second loops. There's a render counter in the test component so the loop fails as an assertion instead of hanging CI.