fix: retry error boundary queries on remount#10822
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR refines React Query's error boundary retry logic by expanding the retry-prevention condition in ChangesError Boundary Query Remount Retry Behavior
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx (1)
483-488: ⚡ Quick winTest doesn't exercise the "previous reset" it claims.
shouldResetis set totrue(Line 484) and back tofalse(Line 491) with nofireEvent.clickin between, soonReset(and thusreset()) never fires whileshouldResetistrue. The middle block is dead code that only re-asserts the boundary is still shown; the named "after a previous reset" path is never executed. Add the missing interaction so a reset-based retry actually occurs before the final remount-without-reset assertion.With the click, `onReset` runs `reset()` (since `shouldReset` is `true`), causing a reset-based retry that fails again (`succeed` still `false`); `useClearResetErrorBoundary` then clears the reset on remount, so the final block (`shouldReset = false`) genuinely tests retry-on-remount without a reset.💚 Trigger the reset-based retry in the middle block
succeed = false shouldReset = true + fireEvent.click(rendered.getByText('retry')) await vi.advanceTimersByTimeAsync(11) expect(rendered.getByText('error boundary')).toBeInTheDocument() expect(rendered.getByText('retry')).toBeInTheDocument()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx` around lines 483 - 488, The test sets shouldReset = true then resets it to false without triggering the reset path, so add the missing user interaction to invoke onReset/reset(): after setting shouldReset = true and before setting shouldReset = false, call the UI interaction that clicks the retry button (e.g., fireEvent.click(rendered.getByText('retry')) or the equivalent used in this test) so that reset() is executed while shouldReset is true; this will exercise the "previous reset" path and allow the final block (shouldReset = false) to truly test retry-on-remount without a reset.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx`:
- Around line 483-488: The test sets shouldReset = true then resets it to false
without triggering the reset path, so add the missing user interaction to invoke
onReset/reset(): after setting shouldReset = true and before setting shouldReset
= false, call the UI interaction that clicks the retry button (e.g.,
fireEvent.click(rendered.getByText('retry')) or the equivalent used in this
test) so that reset() is executed while shouldReset is true; this will exercise
the "previous reset" path and allow the final block (shouldReset = false) to
truly test retry-on-remount without a reset.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4dbdcf70-0ac8-4daa-9280-b3a229835da0
📒 Files selected for processing (2)
packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsxpackages/react-query/src/errorBoundaryUtils.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
❌ Failed | 2m 53s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 28s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-05-29 15:41:05 UTC
TkDodo
left a comment
There was a problem hiding this comment.
you’re changing tests to match the new behaviour ? additionally, there are more failing tests. The problem is react rendering the component an additional time even after an error has been thrown before the errorBoundary renders.

Fixes #2712
Summary
Validation
..\..\node_modules\.bin\vitest.CMD QueryResetErrorBoundary.test.tsx --runfrompackages\react-query(14 tests passed)Summary by CodeRabbit
Bug Fixes
Tests