Skip to content

RTK Query does not trigger fetch in background tabs until document gains focus at least once #5051

@suryateja-7

Description

@suryateja-7

When using RTK Query in a React + Redux Toolkit application, queries are not executed immediately if the page is opened in a background tab (e.g., via Ctrl + Click / Cmd + Click). The fetch is deferred until the document receives focus for the first time.

This behavior breaks expected UX for users who open multiple links in background tabs, since no network requests are made until they manually switch to each tab. This can cause noticeable delays in rendering data when they finally open the tab.

Steps to reproduce:

  1. Open any page that triggers an RTK Query fetch in a background tab using Ctrl + Click / Cmd + Click.
  2. Do not switch focus to the new tab.
  3. Observe that no network request is sent until the tab gains focus.

How I reproduced -
Created a Query which will fetch an array of posts & I added a logic to set the document.title to posts.count.
Until I attained tab focus, the title is undefined only, as soon as focus is attained the api is fetched and title got populated correctly.

Expected behavior:
Queries should execute immediately on mount, even in background tabs, without requiring the document to gain focus.

Environment:
Redux Toolkit version: "@reduxjs/toolkit": "^2.6.1",

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