浏览代码

[editor] Only cancel queries that are actually running when executing a new query

Johan Ahlen 5 年之前
父节点
当前提交
6dbf85a973

+ 7 - 5
desktop/core/src/desktop/js/apps/notebook2/execution/apiUtils.ts

@@ -217,16 +217,18 @@ export const executeStatement = async (options: ExecuteApiOptions): Promise<Exec
 
   executable.addCancellable({
     cancel: async () => {
+      if (executable.status !== EXECUTION_STATUS.running) {
+        return;
+      }
       try {
         const response = await executePromise;
         if (options.executable.handle !== response.handle) {
           options.executable.handle = response.handle;
         }
-        await cancelStatement(options);
-      } catch (err) {
-        console.warn('Failed cancelling statement');
-        console.warn(err);
-      }
+        if (response.handle) {
+          await cancelStatement(options);
+        }
+      } catch (err) {}
     }
   });
 

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/executable.ts

@@ -260,7 +260,7 @@ export default abstract class Executable {
 
     let actualCheckCount = statusCheckCount || 0;
     if (!statusCheckCount) {
-      this.cancellables.push({
+      this.addCancellable({
         cancel: () => {
           window.clearTimeout(checkStatusTimeout);
         }