Reset the query cache when a pane boundary recovers - #15341
Draft
mtsgrd wants to merge 1 commit into
Draft
Conversation
A suspense query keeps throwing its cached error until the query cache is reset, so clearing the boundary's own state is not enough: the children render straight back into the same throw. Neither pane boundary was handed that reset, and the details pane cleared its error during render via getDerivedStateFromProps, which is too early for onReset to run at all -- so a failed query left the pane stuck, with Retry unable to help. Move the reset to the commit phase so onReset runs before the children render again, and give both panes the reset from useQueryErrorResetBoundary. The extra render pass this costs is the point, not an oversight. ErrorBoundary.query.test.tsx covers both routes back, on a reset key and on Retry; both fail without the onReset call. Follows up #15339, raised there by Copilot.
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.
Follow-up to #15339, which merged before Copilot's review could be acted on. Copilot was right, and this fixes it.
The bug
The pane error boundaries from #15339 could clear their own state but never reset the query cache. A
useSuspenseQuerykeeps throwing its cached error untilreset()is called, so the children rendered straight back into the same throw.Two things had to be wrong together, and both were:
onResetuseQueryErrorResetBoundary()getDerivedStateFromProps— too early foronResetto run at allonResetruns before children re-renderNet effect: a failed suspense query in the details pane was stuck permanently, and Retry could not help — exactly the "quiet dead pane" failure the
resetKeyswork was meant to prevent.Details.tsxhas 4useSuspenseQuerycall sites, so this was reachable.The fix
ErrorBoundaryresets incomponentDidUpdaterather thangetDerivedStateFromProps. The extra render pass is the point:onResetmust land before the children render again.WorkspacePagepassonReset={resetQueryErrors}.Verification
ErrorBoundary.query.test.tsxdrives a realQueryClientwith a failing suspense query and covers both routes back — via a reset key, and via Retry.Both tests fail if the
onResetcall is removed, so they guard the actual defect rather than the shape of the code:pnpm -F @gitbutler/lite check, component tests (27 passing),oxlint,knip— clean.