Skip to content

Commit

Permalink
fix(sqllab): Add abort call on query refresh timeout (#29956)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark authored Aug 16, 2024
1 parent a225f32 commit 6e1ef19
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
acc[current.id] = current;
return acc;
}, {}) ?? {};
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;
});
Expand Down

0 comments on commit 6e1ef19

Please sign in to comment.