Skip to content

Add retry, staleTime, and refetchOnWindowFocus query options#66

Open
KidkArolis wants to merge 1 commit intore-orderfrom
retries-and-window-focus
Open

Add retry, staleTime, and refetchOnWindowFocus query options#66
KidkArolis wants to merge 1 commit intore-orderfrom
retries-and-window-focus

Conversation

@KidkArolis
Copy link
Collaborator

New query configuration options for resilience and freshness control:

  • retry: Automatic retry with exponential backoff on fetch failures
    (default: 3 retries, 1s→2s→4s... capped at 30s)
  • retryDelay: Custom delay function or fixed ms between retries
  • staleTime: Time data is considered "fresh" before background refetch
    (default: 30s - prevents refetch storms from rapid tab switching)
  • refetchOnWindowFocus: Refetch stale queries when window regains focus
    (default: true - catches missed realtime events after dormancy)

All options work as global defaults via Figbird constructor:

new Figbird({
  adapter,
  defaultQueryConfig: {
    retry: 3,
    staleTime: 60_000,
    refetchOnWindowFocus: true,
  }
})

Or as per-query overrides:

useFind('messages', { staleTime: 0, retry: false })

The 30s default staleTime balances two concerns:

  • Realtime events keep data fresh in normal operation
  • Refetch catches edge cases (laptop sleep, background tab throttling)
  • Rapid tab switching won't cause refetch storms

  New query configuration options for resilience and freshness control:

  - retry: Automatic retry with exponential backoff on fetch failures
    (default: 3 retries, 1s→2s→4s... capped at 30s)
  - retryDelay: Custom delay function or fixed ms between retries
  - staleTime: Time data is considered "fresh" before background refetch
    (default: 30s - prevents refetch storms from rapid tab switching)
  - refetchOnWindowFocus: Refetch stale queries when window regains focus
    (default: true - catches missed realtime events after dormancy)

  All options work as global defaults via Figbird constructor:

    new Figbird({
      adapter,
      defaultQueryConfig: {
        retry: 3,
        staleTime: 60_000,
        refetchOnWindowFocus: true,
      }
    })

  Or as per-query overrides:

    useFind('messages', { staleTime: 0, retry: false })

  The 30s default staleTime balances two concerns:
  - Realtime events keep data fresh in normal operation
  - Refetch catches edge cases (laptop sleep, background tab throttling)
  - Rapid tab switching won't cause refetch storms
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