Skip to content

Commit

Permalink
Merge pull request #1106 from martinRenou/add_timeout_control
Browse files Browse the repository at this point in the history
Add timeout on the control comm target
  • Loading branch information
trungleduc authored Mar 7, 2022
2 parents 88565eb + 6ffcb18 commit d2220dd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/voila/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d2220dd

Please sign in to comment.