diff --git a/packages/voila/src/manager.ts b/packages/voila/src/manager.ts index 08f46f704..05668b8ab 100644 --- a/packages/voila/src/manager.ts +++ b/packages/voila/src/manager.ts @@ -70,6 +70,11 @@ if (typeof window !== 'undefined' && typeof window.define !== 'undefined') { const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget-view+json'; +/** + * Time (in ms) after which we consider the control comm target not responding. + */ +export const CONTROL_COMM_TIMEOUT = 4000; + /** * A custom widget manager to render widgets with Voila */ @@ -238,6 +243,12 @@ export class WidgetManager extends JupyterLabManager { // Send a states request msg initComm.send({ method: 'request_states' }, {}); + + // Reject if we didn't get a response in time + setTimeout( + () => reject('Control comm did not respond in time'), + CONTROL_COMM_TIMEOUT + ); }); } catch (error) { console.warn(