mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: guard per-chat cancelQueries to prevent 'Chat not found' race (#23714)
This commit is contained in:
@@ -471,10 +471,17 @@ const AgentsPage: FC = () => {
|
||||
// title generation finished, so its response carries
|
||||
// the fallback title.
|
||||
void cancelChatListQueries(queryClient);
|
||||
void queryClient.cancelQueries({
|
||||
queryKey: chatKey(updatedChat.id),
|
||||
exact: true,
|
||||
});
|
||||
// Only cancel a per-chat refetch when the cache
|
||||
// already has data. Cancelling a first-time fetch
|
||||
// reverts the query to pending/idle with no data
|
||||
// and no retry, which AgentDetail shows as
|
||||
// "Chat not found".
|
||||
if (queryClient.getQueryData(chatKey(updatedChat.id))) {
|
||||
void queryClient.cancelQueries({
|
||||
queryKey: chatKey(updatedChat.id),
|
||||
exact: true,
|
||||
});
|
||||
}
|
||||
|
||||
// For "created" events, use a cross-page existence
|
||||
// check and prepend only to the first page.
|
||||
|
||||
Reference in New Issue
Block a user