jupyter / services

This repository is deprecated. It has been moved to https://github.com/jupyterlab/jupyterlab as a sub-package
BSD 3-Clause "New" or "Revised" License
72 stars 45 forks source link

Terminal session connection failure edge case. #318

Closed afshin closed 7 years ago

afshin commented 7 years ago

When JupyterLab tries to restore its UI state and re-open terminals, it applies this logic:

// If a session name exists, try to connect to that terminal session.
let promise = name ?
  services.terminals.connectTo(name)
    // If unable to connect to a name that exists, start new terminal session.
    .catch(() => services.terminals.startNew())
  // If no name exists, start a new terminal session.
  : services.terminals.startNew();

// Irrespective of how a terminal was generated (whether retrieved or
// newly created), associate that session with a terminal widget.
return promise.then(session => {
  term.session = session;
  tracker.add(term);
  tracker.activate(term);
}).catch(() => { term.dispose(); });

This logic works on normal refreshes. However:

  1. If you stop your jupyter server while keeping your browser session open.
  2. Then you restart the server.
  3. Then you refresh your browser.

You'll see the terminal widgets created, but they will hang because the session that is associated with the widget never seems to have an active web socket connection. This only fails the first time after the server is restarted. If you refresh a second time everything works as expected.

The broken state looks like this:

stalled terminal