Skip to content

RTKQ: Delayed invalidationBehavior issue with long running queries #4347

Open
@MateuszGroth

Description

@MateuszGroth

Issue description

Whenever there is a pending query on some endpoint 'A', invalidation of cache (re-fetch when subscribed) on endpoint 'B' is only triggered when the endpoint 'A' query finishes.

Consider a scenario where you have two queries getPosts and getMyPosts. Let's assume that getPosts takes around 25 seconds to finish and getMyPosts returns data immediately (200ms).

Steps to reproduce:

  • Subscribe to getPosts and getMyPosts
  • invalidate getMyPosts after a couple of seconds (while getPosts query is still pending)

Expected result:

  • my posts data is re-fetched right after the invalidation (delayed as a task/microTask)

Actual result:

  • my posts data is re-fetched only when the getPosts query finishes
"@reduxjs/toolkit": "2.2.1",
"react-redux": "9.1.0",
"redux": "5.0.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions