Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/react-query-5-90.md
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions packages/app/src/hooks/useStreamingQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ export function useStreamingQuery<TItem>({
queryClient.setQueryData<TItem[]>(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
Comment thread
knudtty marked this conversation as resolved.
Resolved
.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;
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading