Skip to content

Commit 43622e7

Browse files
authored
Merge pull request #4443 from minrk/notify-ws-close
trigger _ws_closed on any close event
2 parents e80c770 + 490b8fd commit 43622e7

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

notebook/static/services/kernels/kernel.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -470,33 +470,31 @@ define([
470470

471471
var already_called_onclose = false; // only alert once
472472
var ws_closed_early = function(evt){
473+
console.log("WebSocket closed early", evt);
473474
if (already_called_onclose){
474475
return;
475476
}
476477
already_called_onclose = true;
477-
if ( ! evt.wasClean ){
478-
// If the websocket was closed early, that could mean
479-
// that the kernel is actually dead. Try getting
480-
// information about the kernel from the API call --
481-
// if that fails, then assume the kernel is dead,
482-
// otherwise just follow the typical websocket closed
483-
// protocol.
484-
that.get_info(function () {
485-
that._ws_closed(ws_host_url, false);
486-
}, function () {
487-
that.events.trigger('kernel_dead.Kernel', {kernel: that});
488-
that._kernel_dead();
489-
});
490-
}
478+
// If the websocket was closed early, that could mean
479+
// that the kernel is actually dead. Try getting
480+
// information about the kernel from the API call --
481+
// if that fails, then assume the kernel is dead,
482+
// otherwise just follow the typical websocket closed
483+
// protocol.
484+
that.get_info(function () {
485+
that._ws_closed(ws_host_url, false);
486+
}, function () {
487+
that.events.trigger('kernel_dead.Kernel', {kernel: that});
488+
that._kernel_dead();
489+
});
491490
};
492491
var ws_closed_late = function(evt){
492+
console.log("WebSocket closed unexpectedly", evt);
493493
if (already_called_onclose){
494494
return;
495495
}
496496
already_called_onclose = true;
497-
if ( ! evt.wasClean ){
498-
that._ws_closed(ws_host_url, false);
499-
}
497+
that._ws_closed(ws_host_url, false);
500498
};
501499
var ws_error = function(evt){
502500
if (already_called_onclose){

0 commit comments

Comments
 (0)