Skip to content

Commit 426e0e8

Browse files
committed
jupyter: fix (reported) crash when running cell that doesn't exist
1 parent 2a57c46 commit 426e0e8

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/packages/frontend/jupyter/browser-actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ export class JupyterActions extends JupyterActions0 {
169169
if (this.store.get("read_only")) return;
170170
const cell = this.store.getIn(["cells", id]);
171171
if (cell == null) {
172-
throw Error(`can't run cell ${id} since it does not exist`);
172+
// it is trivial to run a cell that does not exist -- nothing needs to be done.
173+
return;
173174
}
174175

175176
const cell_type = cell.get("cell_type", "code");

src/packages/jupyter/redux/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ export abstract class JupyterActions extends Actions<JupyterStoreState> {
11051105
): void {
11061106
const cell = this.store.getIn(["cells", id]);
11071107
if (cell == null) {
1108-
throw Error(`can't run cell ${id} since it does not exist`);
1108+
// it is trivial to run a cell that does not exist -- nothing needs to be done.
1109+
return;
11091110
}
11101111
const kernel = this.store.get("kernel");
11111112
if (kernel == null || kernel === "") {

src/packages/jupyter/redux/project-actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export class JupyterActions extends JupyterActions0 {
5858
if (this.store.get("read_only")) return;
5959
const cell = this.store.getIn(["cells", id]);
6060
if (cell == null) {
61-
throw Error(`can't run cell ${id} since it does not exist`);
61+
// it is trivial to run a cell that does not exist -- nothing needs to be done.
62+
return;
6263
}
6364
const cell_type = cell.get("cell_type", "code");
6465
if (cell_type == "code") {
@@ -669,9 +670,8 @@ export class JupyterActions extends JupyterActions0 {
669670
// we are done waiting for output from this cell.
670671
// The output handler removes all listeners whenever it is
671672
// finished, so we don't have to remove this listener for done.
672-
handler.once(
673-
"done",
674-
() => this.jupyter_kernel?.removeListener("closed", handleKernelClose),
673+
handler.once("done", () =>
674+
this.jupyter_kernel?.removeListener("closed", handleKernelClose),
675675
);
676676

677677
handler.on("more_output", (mesg, mesg_length) => {

0 commit comments

Comments
 (0)