Skip to content

Commit 6e1ce92

Browse files
Remove observables callbacks when kernel changes (fixes #)
With the notebook ```julia using PlotlyJS, Observables ``` ```julia p = plot(scatter(;y=rand(20)) ``` ```julia on(p["hover"]) do hover @show hover end ``` Run each cell, hover over several points to see everything working. There should be no errors in the browser console related to hover events. Restart the kernel, and then hover over points again. There should be errors for every hover event.
1 parent ef21134 commit 6e1ce92

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

webio_jupyter_extension/webio-jupyter-labextension/labextension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { DocumentRegistry } from "@jupyterlab/docregistry";
88
import type { INotebookModel, NotebookPanel } from "@jupyterlab/notebook";
99
import type { IRenderMime } from "@jupyterlab/rendermime";
1010
import type { Kernel } from "@jupyterlab/services";
11+
import type { IKernelConnection } from "@jupyterlab/services/lib/kernel/kernel";
1112

1213
import WebIO from "@webio/webio";
1314

@@ -222,6 +223,19 @@ class WebIONotebookManager {
222223
log("Received WebIO comm message:", msg);
223224
this._webIO.dispatch(msg.content.data);
224225
};
226+
kernel.statusChanged.connect(
227+
(kernel: IKernelConnection, stat: Kernel.Status) => {
228+
if (
229+
stat === "restarting" ||
230+
stat === "autorestarting" ||
231+
stat === "dead"
232+
) {
233+
// Stop attempting to handle callbacks if previous kernel is gone
234+
this._webIO.setSendCallback((msg: any) => {});
235+
}
236+
},
237+
this,
238+
);
225239

226240
this.setWebIOMetadata(kernel.id, this.comm.commId);
227241
}

0 commit comments

Comments
 (0)