Skip to content

streamline cancelRefetch #2916

Closed
Closed
@TkDodo

Description

@TkDodo

It is currently not clear when a previously ongoing fetch will be cancelled. Imperative methods that trigger refetches behave differently per default, like:

refetch returned from useQuery defaults cancelRefetch to false
invalidateQueries, refetchQueries and resetQueries default cancelRefetch to false
fetchNextPage and fetchPreviousPage returned from useInfiniteQuery default cancelRefetch to true
As discussed on Twitter, not cancelling a refetch when you explicitly call one of the above methods might lead to wrong data being displayed / getting out-of-sync with the backend. The safer approach would be to always cancel when the user explicitly requests a refetch with one of the above mentioned options.

Proposed solution

  • Set the cancelRefetch flag to true per default on all imperative actions that support it
  • Users can opt-out by setting it to false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions