File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
containers/Tenant/Query/QueryEditor Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ export default function QueryEditor(props: QueryEditorProps) {
144144 }
145145 const queryId = uuidv4 ( ) ;
146146
147+ // Abort previous query if there was any
148+ queryManagerInstance . abortQuery ( ) ;
149+
147150 if ( isStreamingEnabled ) {
148151 const query = streamQuery ( {
149152 actionType : 'execute' ,
Original file line number Diff line number Diff line change @@ -296,6 +296,10 @@ export const queryApi = api.injectEndpoints({
296296 return { data : null } ;
297297 } catch ( error ) {
298298 const state = getState ( ) as RootState ;
299+ if ( state . query . result ?. startTime !== startTime ) {
300+ // This query is no longer current, don't update state
301+ return { error} ;
302+ }
299303 dispatch (
300304 setQueryResult ( {
301305 ...state . query . result ,
@@ -321,7 +325,7 @@ export const queryApi = api.injectEndpoints({
321325 enableTracingLevel,
322326 queryId,
323327 } ,
324- { signal, dispatch} ,
328+ { signal, dispatch, getState } ,
325329 ) => {
326330 const startTime = Date . now ( ) ;
327331 dispatch (
@@ -410,6 +414,11 @@ export const queryApi = api.injectEndpoints({
410414 ) ;
411415 return { data : null } ;
412416 } catch ( error ) {
417+ const state = getState ( ) as RootState ;
418+ if ( state . query . result ?. startTime !== startTime ) {
419+ // This query is no longer current, don't update state
420+ return { error} ;
421+ }
413422 dispatch (
414423 setQueryResult ( {
415424 type : actionType ,
You can’t perform that action at this time.
0 commit comments