Skip to content

Commit 5e5ed62

Browse files
committed
Add timeout on the control comm target
So that if we don't get a response in time, we fallback to the old implementation of fetching the widgets
1 parent 88565eb commit 5e5ed62

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/voila/src/manager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ if (typeof window !== 'undefined' && typeof window.define !== 'undefined') {
7070

7171
const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json';
7272

73+
/**
74+
* Time (in ms) after which we consider the control comm target not responding.
75+
*/
76+
export const CONTROL_COMM_TIMEOUT = 4000;
77+
7378
/**
7479
* A custom widget manager to render widgets with Voila
7580
*/
@@ -238,6 +243,12 @@ export class WidgetManager extends JupyterLabManager {
238243

239244
// Send a states request msg
240245
initComm.send({ method: 'request_states' }, {});
246+
247+
// Reject if we didn't get a response in time
248+
setTimeout(
249+
() => reject('Control comm did not respond in time'),
250+
CONTROL_COMM_TIMEOUT
251+
);
241252
});
242253
} catch (error) {
243254
console.warn(

0 commit comments

Comments
 (0)