Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 31aeb5f

Browse files
committed
[PR #322] Protect against a potential timing error in the model creation logic
2 parents fdcf7a5 + 0dbc173 commit 31aeb5f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

elements/urth-core-behaviors/jupyter-widget-behavior.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
widget_class: this.kernelClass
5353
}
5454
).then(function(model) {
55+
//This check is to protect against a timing in ipywidgets where the comm can be close
56+
//by the time it gets to resolve this promise
57+
if(!model.comm.kernel.comm_manager.comms[model.comm.comm_id]){
58+
this._handleCommDisconnect();
59+
return;
60+
}
61+
5562
console.log('Model creation successful!', model);
5663
this.__modelChangeCallback = this._onModelChange.bind(this);
5764
this.__commCloseCallback = this._handleCommDisconnect.bind(this);

0 commit comments

Comments
 (0)