Skip to content

feat: handle retry and cancellations#474

Merged
Agilulfo1820 merged 1 commit into
mainfrom
feat/react-query-retries
Oct 31, 2025
Merged

feat: handle retry and cancellations#474
Agilulfo1820 merged 1 commit into
mainfrom
feat/react-query-retries

Conversation

@Agilulfo1820

Copy link
Copy Markdown
Member

Description

On VeBetter I am seeing this error:

client-wrapper.tsx:37 A query that was dehydrated as pending ended up rejecting. [["VECHAIN_KIT_DOMAIN","0x3f90bf8b314c42005103b3c94505634fa680dcee"]]: Error: CancelledError; The error will be redacted in production builds

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 CancelledError warning 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):

  • next-template
  • homepage
  • vechain-kit
  • contracts

@Agilulfo1820 Agilulfo1820 requested a review from a team October 30, 2025 17:07
@Agilulfo1820 Agilulfo1820 merged commit 8375571 into main Oct 31, 2025
6 checks passed
@Agilulfo1820 Agilulfo1820 deleted the feat/react-query-retries branch October 31, 2025 08:05
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.

1 participant