From 970fba04174324f9dda4774cb46c5a8182864095 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Fri, 22 Nov 2019 10:13:27 -0800 Subject: [PATCH] Handle cell execution cancellation because cell is disposed. Fixes #7554 --- packages/cells/src/widget.ts | 5 +++-- packages/notebook/src/actions.tsx | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cells/src/widget.ts b/packages/cells/src/widget.ts index a2de99732cd2..7556e8c03d4e 100644 --- a/packages/cells/src/widget.ts +++ b/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; diff --git a/packages/notebook/src/actions.tsx b/packages/notebook/src/actions.tsx index bf90714c5439..fe6a0ff49375 100644 --- a/packages/notebook/src/actions.tsx +++ b/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) {