From 4daf6fe8b78fc79afdfc9f4dbdbb99e9690b52cb Mon Sep 17 00:00:00 2001 From: Aaron Knudtson <87577305+knudtty@users.noreply.github.com> Date: Mon, 19 Oct 2026 14:13:19 -0400 Subject: [PATCH] chore: upgrade React Query to 5.90 and keep cancelled streams out of 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. --- .changeset/react-query-5-90.md | 6 ++++ packages/app/src/hooks/useStreamingQuery.tsx | 13 ++++++++ yarn.lock | 34 ++++++++++---------- 3 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 .changeset/react-query-5-90.md diff --git a/.changeset/react-query-5-90.md b/.changeset/react-query-5-90.md new file mode 100644 index 0000000000..c2829c599d --- /dev/null +++ b/.changeset/react-query-5-90.md @@ -0,0 +1,6 @@ +--- +'@hyperdx/app': patch +--- + +chore: upgrade @tanstack/react-query to 5.90 and keep a cancelled filter +values stream's partial results out of the cache diff --git a/packages/app/src/hooks/useStreamingQuery.tsx b/packages/app/src/hooks/useStreamingQuery.tsx index 2812c90837..490bc7ed08 100644 --- a/packages/app/src/hooks/useStreamingQuery.tsx +++ b/packages/app/src/hooks/useStreamingQuery.tsx @@ -104,6 +104,19 @@ export function useStreamingQuery({ queryClient.setQueryData(queryKey, [...accumulated]); }; + // Since React Query 5.85, a cancelled fetch reverts to its last + // `setQueryData` write instead of its pre-fetch state, which would cache + // a superseded stream's partial result as complete. + const cachedQuery = queryClient + .getQueryCache() + .find({ queryKey, exact: true }); + const stateBeforeStream = cachedQuery?.state; + signal.addEventListener('abort', () => { + if (stateBeforeStream && lastFlushedAt > -Infinity) { + cachedQuery?.setState({ ...stateBeforeStream, fetchStatus: 'idle' }); + } + }); + try { for await (const chunk of streamFactory({ signal })) { if (signal.aborted) break; diff --git a/yarn.lock b/yarn.lock index dd87de2efb..eea5b3afc5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10838,40 +10838,40 @@ __metadata: languageName: node linkType: hard -"@tanstack/query-core@npm:5.56.2": - version: 5.56.2 - resolution: "@tanstack/query-core@npm:5.56.2" - checksum: 10c0/54ff55f02b01f6ba089f4965bfd46f430c18ce7e11d874de04c4d58cc8f698598b41e1c017ba029d08ae75e321e546b26f1ea7f788474db265eeba46e780f2f6 +"@tanstack/query-core@npm:5.90.20": + version: 5.90.20 + resolution: "@tanstack/query-core@npm:5.90.20" + checksum: 10c0/70637dfcecd5ed9d810629aa27f1632af8a4bcd083e75cf29408d058c32f8234704a3231ec280e2c4016ea0485b16124fdf70ab97793b5a7b670f43f7659e9fe languageName: node linkType: hard -"@tanstack/query-devtools@npm:5.56.1": - version: 5.56.1 - resolution: "@tanstack/query-devtools@npm:5.56.1" - checksum: 10c0/4f50fccf9e731e0fee4b7d2344cd8bf73a9c45816d7361f54ca4ec2df0a0455bf400fa3b578279edc8a4d1013c52c0d90cd50dbffb133edcf52e55868468d6c3 +"@tanstack/query-devtools@npm:5.93.0": + version: 5.93.0 + resolution: "@tanstack/query-devtools@npm:5.93.0" + checksum: 10c0/0024cef103f48c50f3932f6bfe5d77b4fde25be49d43486f8ef7ec7108d2c1bd999ebc7a46309f0504bf081daa7217b36637e9436d67f9a1599c89a385d078ee languageName: node linkType: hard "@tanstack/react-query-devtools@npm:^5.56.2": - version: 5.56.2 - resolution: "@tanstack/react-query-devtools@npm:5.56.2" + version: 5.91.3 + resolution: "@tanstack/react-query-devtools@npm:5.91.3" dependencies: - "@tanstack/query-devtools": "npm:5.56.1" + "@tanstack/query-devtools": "npm:5.93.0" peerDependencies: - "@tanstack/react-query": ^5.56.2 + "@tanstack/react-query": ^5.90.20 react: ^18 || ^19 - checksum: 10c0/2edebb04800585da1ca479f9289a9265cfcc26c5d8fb1db08e6fbe9fdf370a55a2007416b52f819c2faeab7b919cd51a4afca7731b50b6f3dd164057e4966741 + checksum: 10c0/cbd9ce85698511e80955f2c7d0fa7395f3230b34a8cbfb6be1712d49393fc4e06a0a2b5ecd734dff9e803834a7c2c347c954ca4b76f961ccf4c31be39e7ac0bc languageName: node linkType: hard "@tanstack/react-query@npm:^5.56.2": - version: 5.56.2 - resolution: "@tanstack/react-query@npm:5.56.2" + version: 5.90.21 + resolution: "@tanstack/react-query@npm:5.90.21" dependencies: - "@tanstack/query-core": "npm:5.56.2" + "@tanstack/query-core": "npm:5.90.20" peerDependencies: react: ^18 || ^19 - checksum: 10c0/6e883b4ca1948f990215b7bce194251faf13a79c6ecf3f3c660af6c6788ed113ab629cefdafb496dfb04866f12dd48d7314e936b75c881b6749127b6496ac8fd + checksum: 10c0/e8994c57f6ceb2c886a4d6486a8c6a3f89bc6b1220de3e732448d7fcbeb386e9358f03c73804de72004c6ac2668d0bf1b44cedbb273d3e4b33afcbaee7b7d24d languageName: node linkType: hard