Skip to content

Commit

Permalink
fix: shutdown jupyter session on page unload (#4006)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnyama authored Jun 28, 2024
1 parent 93267c5 commit b587bb4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/client/hmi-client/src/services/jupyter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export class KernelSessionManager {
console.log('waiting...', this.jupyterSession?.session?.kernel);
counter++;
if (this.jupyterSession?.session?.kernel) {
window.addEventListener('beforeunload', this.shutdown.bind(this)); // bind(this) ensures that this instance of the class is used
clearInterval(id);
resolve(true);
}
Expand Down Expand Up @@ -318,6 +319,7 @@ export class KernelSessionManager {
}

shutdown() {
window.removeEventListener('beforeunload', this.shutdown.bind(this)); // bind(this) ensures that this instance of the class is used
this.jupyterSession?.shutdown();
}
}

0 comments on commit b587bb4

Please sign in to comment.