Skip to content

Commit 8c3396f

Browse files
author
Taran Rorem
committed
fix(websockets): add ping responses to avoid timeouts from tornado websockets
1 parent 147ecd9 commit 8c3396f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/voila/src/plugins/outputs/plugins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ export const renderOutputsProgressivelyPlugin: JupyterFrontEndPlugin<void> = {
154154
console.error(`Execution error: ${payload.error}`);
155155
break;
156156
}
157+
case 'ping': {
158+
ws.send(JSON.stringify({ action: 'pong' }));
159+
break;
160+
}
157161
default:
158162
break;
159163
}

packages/voila/src/plugins/outputs/tools.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ export interface IExecutionErrorMessage {
2727
};
2828
}
2929

30+
/**
31+
* Interface representing the structure of an execution's ping and pong message.
32+
*/
33+
export interface IExecutionResultPingMessage {
34+
action: 'ping';
35+
payload: any;
36+
}
37+
3038
/**
3139
* Interface representing a received widget model
3240
* containing output and execution models.
@@ -39,7 +47,8 @@ export interface IReceivedWidgetModel {
3947
}
4048
export type IExecutionMessage =
4149
| IExecutionResultMessage
42-
| IExecutionErrorMessage;
50+
| IExecutionErrorMessage
51+
| IExecutionResultPingMessage;
4352

4453
export function getExecutionURL(kernelId?: string): string {
4554
const wsUrl = PageConfig.getWsUrl();

0 commit comments

Comments
 (0)