Fix a subtle async bug in processing comm messages.

Basically, message processing did not wait for any promises a comm message handler may return to resolve, because comms were not set up to resolve return values of message handlers.
Jason Grout 9 years ago
parent 2fd22fa254
commit e2c0b6b5b7

@ -128,12 +128,9 @@ define([
}
this.comms[content.comm_id] = this.comms[content.comm_id].then(function(comm) {
try {
comm.handle_msg(msg);
} catch (e) {
console.log("Exception handling comm msg: ", e, e.stack, msg);
}
return comm;
return (Promise.resolve(comm.handle_msg(msg))
.catch(utils.reject('Exception handling comm message'))
.then(function() {return comm;}));
});
return this.comms[content.comm_id];
};
@ -193,7 +190,7 @@ define([
var callback = this['_' + key + '_callback'];
if (callback) {
try {
callback(msg);
return callback(msg);
} catch (e) {
console.log("Exception in Comm callback", e, e.stack, msg);
}
@ -201,7 +198,7 @@ define([
};
Comm.prototype.handle_msg = function (msg) {
this._callback('msg', msg);
return this._callback('msg', msg);
};
Comm.prototype.handle_close = function (msg) {

Loading…
Cancel
Save