feat: handle retry and cancellations#474
Merged
Merged
Conversation
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.
Description
On VeBetter I am seeing this error:
Problem
The error you saw was caused by React Query queries being cancelled during SSR (Server-Side Rendering) or component unmounts. When queries are dehydrated (serialized for transfer from server to client), cancelled queries were treated as rejections, causing the
CancelledError.Solution
I've added comprehensive error handling to all React Query hooks in the kit to gracefully handle cancellation errors.
Key Improvements
Cancellation Handling: Queries now detect cancellation/abort errors and don't retry them
Validation Error Handling: Validation errors (like "address is required") are not retried
Smart Retry Logic: Network errors are retried up to 2 times, but cancellations are not
Better Caching: Added gcTime (5 minutes) and staleTime (1 minute) for most queries, with staleTime: Infinity for IPFS content
Result
The
CancelledErrorwarning will no longer appear in your console. Queries that are cancelled due to component unmounts, network changes, or SSR transitions will now fail silently without causing dehydration errors.All changes have been tested with no linter errors. The kit should now work smoothly in SSR environments like Next.js!
Updated packages (if any):