Skip to content

chore: upgrade React Query to 5.90 and keep cancelled streams out of the cache - #3406

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
aaron/react-query-5-90
Oct 20, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
aaron/react-query-5-90

Conversation

@knudtty

@knudtty knudtty commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Downstream uses a newer version of react query, I am backporting it to OSS. useStreamingQuery requires a slight alteration to continue intended behavior.

References

  • Linear Issue:
  • Related PRs:

…the cache

Lock @tanstack/react-query at 5.90.21 (query-core 5.90.20) and
react-query-devtools at 5.91.3, the versions the EE build already ships,
so the two run the same React Query.

Since query-core 5.85, a cancelled fetch reverts to its last setQueryData
write instead of its pre-fetch state. useStreamingQuery writes partial
results with setQueryData, so a stream superseded mid-load stayed cached as
a complete result (caught by "does not write a superseded stream into the
cache"). It now restores the pre-stream state on abort.
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 20, 2026 9:02pm UTC
hyperdx-storybook Ready Ready Preview Oct 20, 2026 9:02pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 15e3c74

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 1
  • Production lines changed: 13
  • Branch: aaron/react-query-5-90
  • Author: knudtty

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 123 in total (1.62%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor

1 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/app/package.json:54 — Only yarn.lock was bumped; package.json still allows @tanstack/react-query ^5.56.2 even though the resolved devtools now needs ^5.90.20 → Change @tanstack/react-query and @tanstack/react-query-devtools in packages/app/package.json to ^5.90.21 / ^5.91.3. Right now the declared ranges don't match what is installed (react-query-devtools 5.91.3 has a peer dependency of @tanstack/react-query ^5.90.20), and the 5.85+ cancel behaviour described in the new useStreamingQuery comment is only recorded in the lockfile.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge based on the checked code; no blocking issue was established.

Summary

Upgrades React Query and its devtools, and adds an abort listener to restore the cache state captured before a stream writes partial results.

  • Cancelled streams no longer leave partial results cached as complete answers.
  • The app uses React Query 5.90 and matching newer devtools.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into aaron/react-que..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

Upgrade of @tanstack/react-query 5.56 → 5.90 plus a ~12-line abort handler in useStreamingQuery that restores a query's pre-stream cache state on cancel, so a superseded stream's partial setQueryData writes are not left behind as a "complete" result (React Query 5.85+ reverts a cancelled fetch to its last setQueryData write rather than its pre-fetch state). The core mechanism checks out: query.state is reassigned immutably on each dispatch, so the captured snapshot is a true pre-stream value; the abort listener fires synchronously during abort(); flush-after-abort is guarded; and the primary supersede behavior already has a regression test (useStreamingQuery.test.tsx).

✅ No critical issues found.

🟡 P2 — recommended

  • packages/app/package.json:54 — the manifest still declares @tanstack/react-query and @tanstack/react-query-devtools at ^5.56.2; only yarn.lock moved to 5.90, yet the new abort workaround depends on ≥5.85 cancellation behavior that ^5.56.2 does not guarantee, so a lockfile regeneration or cross-workspace dedup to a pre-5.85 version would silently turn the revert into a no-op with no compile error.
    • Fix: bump both declared ranges to ^5.90.x so the manifest encodes the minimum version the code requires.
    • project-standards, kieran-typescript, reliability
🔵 P3 nitpicks (3)
  • packages/app/src/hooks/useStreamingQuery.tsx:110 — queryClient.getQueryCache().find({ queryKey, exact: true }) is now evaluated twice in the same queryFn (once for the isShowingData observer check, once for cachedQuery).

    • Fix: hoist a single const cachedQuery = ... and derive isShowingData from cachedQuery?.observers.some(...).
    • maintainability, kieran-typescript
  • packages/app/src/hooks/useStreamingQuery.tsx:116 — the abort restore reaches into React Query internals (cachedQuery.setState({ ...stateBeforeStream, fetchStatus: 'idle' })), hand-sets a fetchStatus literal, and leaves the snapshot's in-flight fetchMeta on an otherwise-idle state; it is correct under query-core 5.90.20's synchronous-cancel ordering but version-fragile with no type signal if that ordering changes.

    • Fix: extract a documented helper co-located with the 5.85 comment so the internal coupling lives in one spot to revisit on each React Query upgrade.
    • correctness, kieran-typescript, reliability, maintainability
  • packages/app/src/hooks/useStreamingQuery.tsx:115 — the lastFlushedAt > -Infinity guard's no-op arm (abort before any flush) is not exercised by a test.

    • Fix: add a case that cancels a stream before its first flush and asserts the pre-stream cache is left untouched.

Reviewers (10): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, kieran-typescript, julik-frontend-races, reliability, previous-comments.

Testing gaps:

  • First-load abort path (no prior data → restored status: 'pending' + fetchStatus: 'idle') is untested — confirm the query is not left stuck and refetches on next mount.
  • No version-locked regression test pins React Query's 5.85+ cancellation-revert semantics (or the query.state immutability the fix relies on), so a future upgrade that changes either would pass CI silently; the existing supersede test covers the happy path only.

Notes: The same-key cancel-then-refetch race flagged by two reviewers was traced against query-core 5.90.20 and found safe — the restore's setState runs synchronously before the replacement fetch dispatches fetching, so it is immediately superseded rather than clobbering the new fetch; the only residual is the version-durability risk above. docs/solutions/ does not exist (no prior learnings), and the prior PR comments are automated bot notifications (Vercel, changeset) with nothing to verify.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 444 passed • 1 skipped • 1813s

Status Count
✅ Passed 444
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit b9f6170 into main Oct 20, 2026
29 checks passed
@kodiakhq
kodiakhq Bot deleted the aaron/react-query-5-90 branch October 20, 2026 21:08

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 15e3c741 Deployed Oct 20, 2026 by vercel[bot]
Preview – hyperdx-storybook — 15e3c741 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants