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) {