Browse Source

Merge pull request #7555 from jasongrout/fix-7554

Handle cell execution cancellation because cell is disposed.
Steven Silvester 5 years ago
parent
commit
78e7bf2d68
2 changed files with 6 additions and 6 deletions
  1. 3 2
      packages/cells/src/widget.ts
  2. 3 4
      packages/notebook/src/actions.tsx

+ 3 - 2
packages/cells/src/widget.ts

@@ -1108,8 +1108,9 @@ export namespace CodeCell {
       }
       return msg;
     } catch (e) {
-      // If this is still the current execution, clear the prompt.
-      if (e.message === 'Canceled' && cell.outputArea.future === future) {
+      // If we started executing, and the cell is still indicating this
+      // execution, clear the prompt.
+      if (future && !cell.isDisposed && cell.outputArea.future === future) {
         cell.setPrompt('');
       }
       throw e;

+ 3 - 4
packages/notebook/src/actions.tsx

@@ -1555,11 +1555,10 @@ namespace Private {
               }
             })
             .catch(reason => {
-              if (reason.message !== 'Canceled') {
-                throw reason;
+              if (cell.isDisposed || reason.message.startsWith('Canceled')) {
+                return false;
               }
-
-              return false;
+              throw reason;
             })
             .then(ran => {
               if (ran) {