Skip to content

fix: survive runtime-proxy token expiry (~1h) instead of pruning live sessions - #146

Closed
mikewong23571 wants to merge 2 commits into
googlecolab:mainfrom
mikewong23571:fix/token-expiry-self-heal
Closed

mikewong23571 wants to merge 2 commits into
googlecolab:mainfrom
mikewong23571:fix/token-expiry-self-heal

Conversation

@mikewong23571

Copy link
Copy Markdown

Problem

The runtime-proxy token expires after ~1h while the VM assignment stays alive. colab exec then gets 401/404, prints 'Session appears to be lost', deletes the local session entry — every later command says 'Session not found' although the VM is still running (visible in the Colab web UI). Re-creating sessions piles up live assignments until TooManyAssignmentsError (412).

Fix

  1. State.refresh_session(): fetch fresh token/url via list_assignments() (verified: it hands out a fresh 3600s token) and update the stored session in place.
  2. exec/repl/console terminal-error paths: refresh + persist credentials, exit code 2, session kept — a fresh process with refreshed credentials reconnects reliably; prune only when no live assignment matches server-side.
  3. runtime.py: top-level jupyter_kernel_client.JupyterSubprotocol crashes on jkc>=1.0 (moved into wsclient); resolve defensively and omit the kwarg when unavailable.
  4. Kernel-connect probe wrapped in a daemon-thread wall-clock timeout (45s) — ThreadPoolExecutor's shutdown(wait=True) still blocks on a hung connect, so a daemon thread is required.

Tested end-to-end: corrupted stored token → exec prints refresh message, keeps session, persists fresh credentials → re-run reconnects.

… sessions

- common: State.refresh_session() re-reads fresh token/url from list_assignments
- exec/repl/console: on 401/404 refresh credentials + persist (exit 2, no prune);
  only prune when no live assignment matches server-side
- runtime: resolve JupyterSubprotocol from wsclient submodule (jkc>=1.0 dropped
  the top-level re-export), omit kwarg when unavailable
- connect probe wrapped in daemon-thread wall-clock timeout (45s) so a wedged
  kernel connect can never hang the CLI
@google-cla

google-cla Bot commented Sep 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant