Skip to content

"Duplicate Queries found" warning, incorrectly logging when creating a QueriesObserver instance #8431

@nick-avi-say

Description

@nick-avi-say

Describe the bug

The duplicate keys check occurs prior to default options being set on the queries which generates the queryHash.

The below contains 2 unique query key's. However the duplicate keys warning logs since these queries are checked as-is and they do not yet have a queryHash.

const observer = new QueriesObserver(queryClient, [ { queryKey: [ 'Hippo', 'Layout', 'detail', 'id1', ], }, { queryKey: [ 'Hippo', 'Layout', 'detail', 'id2', ], }, ])

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/55fr36

Steps to reproduce

  1. Create a QueryObserver instance with 2 queries with 2 unique keys. Do not provide a custom queryHash.
  2. View the warning in your console

(CTA set up to do this for you in the codesandbox)

Expected behavior

We expect unique keys to not throw a duplicate key console warning.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

All

Tanstack Query adapter

None

TanStack Query version

v5.62.7

TypeScript version

No response

Additional context

No response

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