Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file upload widget (fixes to sending binary data to kernel) #14867

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/kernels/raw/session/rawSocket.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading