Skip to content

Commit ff24e2f

Browse files
authored
fix: fix error with dashboard filters when global async queries is enabled and user navigates quickly (#36639)
1 parent 54eb631 commit ff24e2f

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

superset-frontend/src/components/Chart/chartAction.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,16 @@ export function exploreJSON(
476476
return dispatch(chartUpdateSucceeded(queriesResponse, key));
477477
})
478478
.catch(response => {
479+
// Ignore abort errors - they're expected when filters change quickly
480+
const isAbort =
481+
response?.name === 'AbortError' || response?.statusText === 'abort';
482+
if (isAbort) {
483+
// Abort is expected: filters changed, chart unmounted, etc.
484+
return dispatch(chartUpdateStopped(key));
485+
}
486+
479487
if (isFeatureEnabled(FeatureFlag.GlobalAsyncQueries)) {
488+
// In async mode we just pass the raw error response through
480489
return dispatch(chartUpdateFailed([response], key));
481490
}
482491

@@ -494,10 +503,7 @@ export function exploreJSON(
494503
}),
495504
);
496505
};
497-
if (response.name === 'AbortError') {
498-
appendErrorLog('abort');
499-
return dispatch(chartUpdateStopped(key));
500-
}
506+
501507
return getClientErrorObject(response).then(parsedResponse => {
502508
if (response.statusText === 'timeout') {
503509
appendErrorLog('timeout');

superset-frontend/src/components/Chart/chartActions.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,28 @@ describe('chart actions', () => {
357357
});
358358
});
359359

360+
test('should dispatch CHART_UPDATE_STOPPED action upon abort', () => {
361+
fetchMock.post(
362+
MOCK_URL,
363+
{ throws: { name: 'AbortError' } },
364+
{ overwriteRoutes: true },
365+
);
366+
367+
const timeoutInSec = 100;
368+
const actionThunk = actions.postChartFormData({}, false, timeoutInSec);
369+
370+
return actionThunk(dispatch, mockGetState).then(() => {
371+
const types = dispatch.args
372+
.map(call => call[0] && call[0].type)
373+
.filter(Boolean);
374+
375+
expect(types).toContain(actions.CHART_UPDATE_STOPPED);
376+
expect(types).not.toContain(actions.CHART_UPDATE_FAILED);
377+
378+
setupDefaultFetchMock();
379+
});
380+
});
381+
360382
test('should handle the bigint without regression', async () => {
361383
getExploreUrlStub.restore();
362384
const mockBigIntUrl = '/mock/chart/data/bigint';

0 commit comments

Comments
 (0)