Skip to content

Fix ErrorBoundary retry test: resolve re-throw race condition#9

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/test-all-code-in-repo
Draft

Fix ErrorBoundary retry test: resolve re-throw race condition#9
Copilot wants to merge 2 commits intomasterfrom
copilot/test-all-code-in-repo

Conversation

Copy link

Copilot AI commented Feb 23, 2026

The "provides try again button that resets error state" test was failing because clicking "Try Again" before providing new children caused a re-throw cycle: the boundary reset to hasError: false, synchronously re-rendered the still-throwing children, and getDerivedStateFromError fired again before rerender could supply the non-throwing replacement.

Fix

Swap the order of rerender and fireEvent.click in the test to reflect the correct lifecycle: parent provides updated children first, then the user retries.

- fireEvent.click(screen.getByText('Try Again'));
  rerender(
    <ErrorBoundary>
      <ThrowError shouldThrow={false} />
    </ErrorBoundary>
  );
+ fireEvent.click(screen.getByText('Try Again'));

When "Try Again" is clicked, the boundary resets state and renders the already-updated (non-throwing) children, completing the retry successfully.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: nexusct <19503275+nexusct@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze repository and test all code Fix ErrorBoundary retry test: resolve re-throw race condition Feb 23, 2026
Copilot AI requested a review from nexusct February 23, 2026 09:59
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