diff --git a/src/kernels/raw/session/rawSocket.node.ts b/src/kernels/raw/session/rawSocket.node.ts index 7e1c1fca33e..e662bde5a6b 100644 --- a/src/kernels/raw/session/rawSocket.node.ts +++ b/src/kernels/raw/session/rawSocket.node.ts @@ -258,7 +258,17 @@ export class RawSocket implements IWebSocketLike, IKernelSocket, IDisposable { this.sendChain = this.sendChain .then(() => Promise.all(this.sendHooks.map((s) => s(hookData, noop)))) - .then(() => this.postToSocket(msg.channel, data)); + .then(async () => { + try { + await this.postToSocket(msg.channel, data); + } catch (ex) { + traceError(`Failed to write data to the kernel channel ${msg.channel}`, data, ex); + // No point throwing this error, as that would mean nothing else works from here on end. + // Lets ignore this error but log it and then continue + // Hopefully users will file bugs and we can fix this (based on the error message). + // throw ex; + } + }); } else { this.sendChain = this.sendChain.then(() => { this.postToSocket(msg.channel, data); diff --git a/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts b/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts index c81039e6d8c..76fa8951b4e 100644 --- a/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts +++ b/src/notebooks/controllers/ipywidgets/message/ipyWidgetMessageDispatcher.ts @@ -376,7 +376,17 @@ export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher { } while (this.pendingMessages.length) { try { - const msg = JSON.parse(this.pendingMessages[0]) as KernelMessage.IMessage; + const message = this.pendingMessages[0]; + const msg: KernelMessage.IMessage = + typeof message === 'string' ? JSON.parse(message) : this.deserialize(message); + if (msg.buffers?.length) { + msg.buffers = msg.buffers.map((buffer) => { + if (buffer instanceof DataView) { + return buffer.buffer; + } + return buffer; + }); + } if (msg.channel === 'control') { this.kernel.session.kernel!.sendControlMessage(msg as unknown as KernelMessage.IControlMessage); } else {