GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — useQuery does not perform a retry on mount when the function provided to throwOnError returns false, even if retryOnMount: true is set · Issue #9336 · TanStack/query

useQuery does not perform a retry on mount when the function provided to throwOnError returns false, even if retryOnMount: true is set #9336

New issue
Copy link
New issue
Copy link
Closed
#9338
Closed
useQuery does not perform a retry on mount when the function provided to throwOnError returns false, even if retryOnMount: true is set#9336
#9338
Copy link

Description

@andromansky
andromansky
opened on Jun 29, 2025
Issue body actions

Describe the bug

If the query options include the following:

throwOnError: () => false,  
retryOnMount: true,  
staleTime: Infinity,

then on remount of the host component, queryFn is not called, even though the documentation suggests otherwise.

Your minimal, reproducible example

https://stackblitz.com/edit/react-93scwtvo

Steps to reproduce

  1. Wait for the app to load and open the console.
  2. Click the "Open Modal" button — you will see "Fetching..." messages in the console indicating data fetch attempts.
  3. Click the "Close Modal" button.
  4. Click "Open Modal" again — no more "Fetching..." messages appear.

Expected behavior

I expect that if a Query is in the error status and I set retryOnMount: true in the options, then when the function passed to throwOnError returns false, the Query should still call queryFn on remount of the host component.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows, macOS;
  • Browser: Chrome (137.0.7151.120);

Tanstack Query adapter

react-query

TanStack Query version

v5.81.4

TypeScript version

v5.8.3

Additional context

Here is the link to the source code where the condition is checked that forcibly sets retryOnMount to false:

Reacted by Vladislav Mironov and Lvov Valery
Reacted by Vladislav Mironov and Lvov Valery

Activity

  1. sangwook-dev
    added 2 commits that reference this issue on Sep 25, 2025

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    4b795be

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    cd2dd84
  2. sangwook-dev
    added a commit that references this issue on Oct 7, 2025

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    435dd62
  3. sangwook-dev
    added a commit that references this issue on Nov 9, 2025

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    4a2dd73
  4. TkDodo
    added 3 commits that reference this issue on Dec 28, 2025

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    165e133

    Merge branch 'main' into fix/usequery-retry-on-mount-with-throw-on-er…

    c422284

    fix(react-query): allow retryOnMount when throwOnError is function (#…

    4be3ad7
  5. TkDodo
    closed this as completedin #9338on Dec 30, 2025
  6. TkDodo
    marked throwOnError: () => false, avoids query refetch on mount if an error is already set, and there is no data yet (no stale time) #10094 as a duplicate of this issue on Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.