fix(sqllab): Add abort call on query refresh timeout (#29956)

This commit is contained in:
JUST.in DO IT 2024-08-17 06:59:57 +09:00 committed by GitHub
parent a225f329c5
commit 6e1ef193dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -76,28 +76,35 @@ function QueryAutoRefresh({
last_updated_ms: queriesLastUpdate - QUERY_UPDATE_BUFFER_MS,
});
const controller = new AbortController();
pendingRequestRef.current = true;
SupersetClient.get({
endpoint: `/api/v1/query/updated_since?q=${params}`,
timeout: QUERY_TIMEOUT_LIMIT,
parseMethod: 'json-bigint',
signal: controller.signal,
})
.then(({ json }) => {
if (json) {
const jsonPayload = json as { result?: QueryResponse[] };
if (jsonPayload?.result?.length) {
const queries =
jsonPayload?.result?.reduce((acc, current) => {
jsonPayload?.result?.reduce(
(acc: Record<string, QueryResponse>, current) => {
acc[current.id] = current;
return acc;
}, {}) ?? {};
},
{},
) ?? {};
dispatch(refreshQueries(queries));
} else {
dispatch(clearInactiveQueries(QUERY_UPDATE_FREQ));
}
}
})
.catch(() => {})
.catch(() => {
controller.abort();
})
.finally(() => {
pendingRequestRef.current = false;
});