fix(react-query): retry errored queries that mount after the error boundary reset wave 🤖🤖🤖 - #11916
wspperrimh wants to merge 1 commit into
Conversation
… the error boundary reset wave Queries mounting while the reset flag was pending each cleared the shared flag in their mount effect, so the first mounted query consumed the reset before other errored queries could observe it. Track a reset generation and which generation each query last cleared, so every errored query inside the boundary retries once after a reset even when it mounts after siblings already consumed the shared wave. Fixes TanStack#2712
🦋 Changeset detectedLatest commit: e23f009 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
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 |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (13)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughReact Query and Preact Query now track error-boundary resets by query hash. Their retry checks and reset-clearing calls use query-specific state. Regression tests cover an errored query remounting after a sibling query has mounted during the reset. ChangesQuery reset handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Possibly related PRs
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The remount retry regression is covered, and no actionable merge-blocking issue remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves retry isolation and preserves existing zero-argument API usage. The main concern is that reset bookkeeping retains query identities indefinitely in long-lived boundaries, potentially increasing memory consumption. No new authorization bypass or attacker-accessible exploit was established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue [ Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 12 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #2712
🎯 Changes
QueryErrorResetBoundarykept a single sharedisResetflag. The first query that mounted afterreset()cleared it in its mount effect, so any other errored query that mounted later in the boundary — e.g. once its parent re-rendered it — no longer saw the reset, keptretryOnMount: false, and threw its stale error straight back into the boundary.The boundary now tracks a reset generation and which generation each query hash last cleared.
isReset(queryHash)andclearReset(queryHash)take an optional query hash so one query can no longer consume the reset on behalf of its siblings. Callers that don't pass a hash keep the previous shared-flag behavior, so the public API is unchanged.Applied the same fix in
react-queryandpreact-query, and added a regression test in both packages: a healthy sibling query mounts on the reset wave while an errored query mounts later — the errored query must still retry. The test fails on the previous implementation.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit