From 0dbc173b08b48ac4c26d144246251ceef22b808f Mon Sep 17 00:00:00 2001 From: Gino Bustelo Date: Fri, 22 Apr 2016 17:05:09 -0500 Subject: [PATCH] Protect against a potential timing error in the model creation logic (c) Copyright IBM Corp. 2016 --- elements/urth-core-behaviors/jupyter-widget-behavior.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/elements/urth-core-behaviors/jupyter-widget-behavior.html b/elements/urth-core-behaviors/jupyter-widget-behavior.html index af599ddb..0617eef4 100644 --- a/elements/urth-core-behaviors/jupyter-widget-behavior.html +++ b/elements/urth-core-behaviors/jupyter-widget-behavior.html @@ -52,6 +52,13 @@ widget_class: this.kernelClass } ).then(function(model) { + //This check is to protect against a timing in ipywidgets where the comm can be close + //by the time it gets to resolve this promise + if(!model.comm.kernel.comm_manager.comms[model.comm.comm_id]){ + this._handleCommDisconnect(); + return; + } + console.log('Model creation successful!', model); this.__modelChangeCallback = this._onModelChange.bind(this); this.__commCloseCallback = this._handleCommDisconnect.bind(this);