Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable retries in react-query #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/app/src/config/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const queryClient = new QueryClient({
queries: {
gcTime: 1_000 * 60 * 60 * 24, // 24 hours
refetchOnWindowFocus: true,
retry: 0,
retry: 3,
retryDelay: (attemptIndex) => Math.min(150 * 2 ** attemptIndex, 10_000), // reduce the base delay to 150ms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Math.min? it will be always below 10s with 3 retries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case someone overrides the retry prop

staleTime: 1_000 * 60, // 1 minute
},
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { useAccount, useConfig } from 'wagmi'
import { connect, getChains, switchChain } from 'wagmi/actions'

import { createSandboxConnector } from '@/domain/sandbox/createSandboxConnector'
import { useSandboxState } from '@/domain/sandbox/useSandboxState'
import { useStore } from '@/domain/state'
import { NotRetryableError, retry } from '@/utils/promises'
import { getTimestampInSeconds } from '@/utils/time'

import { SandboxMode } from '../types'
import { createSandbox, getChainIdWithPrefix } from './createSandbox'
import { createSandboxConnector } from './createSandboxConnector'

export type UseSandboxMutationResult = Omit<UseMutationResult<void, Error, void, unknown>, 'mutate'> & {
startSandbox: () => void
Expand Down
Loading