Skip to content
Source
Sign inSign up
TanStack/query

Mutations will stay stuck in pending state if network mode is "online" and "mutate" is called when offline #9769

Closedkainbryanjones(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

If you call .mutate on a mutation hook when offline and you have network mode "online" you get stuck in pending state despite the fact that the mutationFn was never called

Your minimal, reproducible example

Just look in the steps to reproduce

Steps to reproduce

  1. Create a hook with useMutation
  2. In the query client mutation default options ensure networkMode is "online" (this is default)
  3. Disconnect from the internet
  4. Ensure you are using isPending in you UI to show some kind of loading state (e.g for a button)
  5. Add onClick handler to mutation

Expected behavior

The pending state should never be true because the mutationFn is never called

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Android WebView

Tanstack Query adapter

react-query

TanStack Query version

^5.90.2

TypeScript version

No response

Additional context

No response

  1. TkDodocommented

    you also get back isPaused: true, so this is expected.

  2. TkDodo closed this

  3. TkDodo added labelsworks as designed

Sign in to join this conversation.