Skip to content

Angular Query's data signal is not updating if data is present in the cache #6567

@shessafridi

Description

@shessafridi

Describe the bug

I am facing an issue with Angular Query regarding query.data signal not emitting new value when the query key changes AND there is already data in the cache

In the devtools the active query is updating as expected but the data signal still has the data of the old (now inactive) query

If data is not in the cache it works as expected by calling the query fn and the data signal emits the latest value

Your minimal, reproducible example

https://github.com/shessafridi/angular-query-data-issue

Steps to reproduce

How to reproduce the issue

  1. Open the browser's console
  2. Click the "Search" button
  3. You will see a message with the start and end date after 2 seconds
  4. Change the date and click the "Search" button again, you should see the message for that date appear as well
  5. Now go back to the date you started with and click "Search" again, you will see the query for that date become active again but this time no message is being logged to the console and the UI is still showing the data for the old date

Expected behavior

I expect the query.data signal to emit new data when the a new query becomes active

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

OS: Windows 11
Browser: Chrome
Angular Query Version: 5.14.2

Tanstack Query adapter

None

TanStack Query version

5.14.2

TypeScript version

5.2.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions