Evaluate signed-zero equality for QueryObserver snapshots
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
Research direction
Start with the signed-zero regression case in packages/query-core/src/__tests__/queryObserver.test.tsx, then read the result comparison in packages/query-core/src/queryObserver.ts and shallowEqualObjects in packages/query-core/src/utils.ts. This issue asks maintainers to decide the intended equality semantics, including effects on notifications, NaN, and snapshot caching; it is design work rather than a scoped first contribution. Done means the behavior is documented and, if changed, regression tests cover the optimistic result, current snapshot, and affected equality and notification behavior.
Written by the indexing model from the issue text.
Description
Summary
Evaluate whether QueryObserver snapshots should distinguish -0 from 0 when selected placeholder data changes. This is a follow-up for maintainers to decide the desired equality semantics; it does not assume that a global equality change is required.
Reproduction and current behavior
In the signed-zero regression case in packages/query-core/src/__tests__/queryObserver.test.tsx, create an observer with enabled: false, placeholderData: 1, structuralSharing: false, and a selector returning -0. Update the options to use a selector returning 0, then call getOptimisticResult with the updated options.
The PR author verified that the optimistic result contains 0, while getCurrentResult().data still contains -0. The shallow comparison treats these values as equal and preserves the current snapshot. The useQuery render in this case uses the optimistic result.
Decision and affected areas
Review the observer result comparison and update behavior in packages/query-core/src/queryObserver.ts and shallowEqualObjects in packages/query-core/src/utils.ts. Consider whether signed zeros should count as different, and whether any change should be local to observer results or use Object.is semantics more broadly. Assess effects on notifications, render optimizations, other equality cases such as NaN, and the useSyncExternalStore snapshot caching contract.
Acceptance criteria
- Maintainers decide and document the intended signed-zero behavior for observer snapshots.
- If a change is warranted, implement the chosen behavior without breaking snapshot stability or notification semantics.
- If a change is made, add regression coverage for the chosen behavior, including the optimistic result and current snapshot, and cover any affected equality and notification behavior.
Context
- Pull request: https://github.com/TanStack/query/pull/12564
- Review discussion: https://github.com/TanStack/query/pull/12564#discussion_r4509388878
- Requested by: @brennanbutler01
- Dominant language
- TypeScript
- Stars
- 50.6k
- Forks
- 4.2k
- Avg merge
- 8h 37m
- Merged PRs (30d)
- 450
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/query
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TanStack/query#12466 · 1 comment ·
Maintainers usually reply within 1 day
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)May be free again @LeonxLJX claimed this 74 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
TanStack/query#11358 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Infinite render loop when select maps keepPreviousData to undefined in v5.105.2+Possibly taken @mooxl claimed this 6 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
TanStack/query#12574 · 1 comment ·
Maintainers usually reply within 1 day
-
infiniteQuery throws "getNextPageParam is not a function" when 2+ stale pages are cachedPossibly taken @abu-tahir-0 claimed this 7 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 42/100
Maintainers usually reply within 1 day
Similar issues
-
Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
OpenNSW/nsw-srilanka#1259 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
oxc-project/tsrs#1010 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Fission-AI/OpenSpec#2260 ·
Maintainers usually reply within 1 day
-
Add: ESP 1 UKOpencheck:passed streams:add
Difficulty 1/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:infra area:storage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
THU-MAIC/OpenMAIC#2311 · 1 comment ·
Maintainers usually reply within 1 day