fix(app): handle CancelledError from cancelled provider usage queries (#1885)

Move canFetch guard before first await so disabled refresh bails out synchronously instead of entering async path. Add .catch() swallow for fire-and-forget call to prevent unhandled promise rejections when react-query cancels pending queries during rapid tooltip open/close cycles.
This commit is contained in:
Slava Goltser
2026-07-08 17:00:57 -04:00
committed by GitHub
parent 202c417347
commit c7406a415d
2 changed files with 2 additions and 4 deletions

View File

@@ -117,7 +117,7 @@ export function ContextWindowMeter({
(nextOpen: boolean) => {
setIsTooltipOpen(nextOpen);
if (nextOpen) {
void refreshProviderUsage();
void refreshProviderUsage().catch(() => {});
}
},
[refreshProviderUsage],

View File

@@ -58,10 +58,8 @@ export function useProviderUsage(
});
const refresh = useCallback(async () => {
if (!canFetch) return;
await queryClient.invalidateQueries({ queryKey });
if (!canFetch) {
return;
}
await queryClient.fetchQuery({
queryKey,
queryFn,