Supervisor: Windows That Connect Before the Handshake Completes Start Their Own Supervisor

Open
#17,669 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, typescript
Domain
backend, devtools

Research direction

Start with server-main.ts, which the issue identifies as setting POSITRON_SUPERVISOR_HANDSHAKE_SOCKET after the pre-warmed kcserver reports in; trace how windows and extension hosts start during that interval. The issue suggests waiting for the pre-warm to settle, but notes that publishing the path early breaks the broker's first-connection behavior. Done when windows use the same supervisor after both successful and failed pre-warm startup, and the reproduction no longer leaves the active session uncounted.

Written by the indexing model from the issue text.

Description

area: kallichore bug

System details:

Positron and OS details:

Positron dev build at 2b039bb54f, server (web) mode, MacOS. kcserver 0.1.78.

Session details:

Python 3.12.8

Describe the issue:

In server mode, server-main.ts only sets POSITRON_SUPERVISOR_HANDSHAKE_SOCKET once the pre-warmed kcserver reports in, but the server is already accepting windows by then. A window whose extension host starts in that gap doesn't get the variable, so it launches its own per-window supervisor while the pre-warmed one sits unused.

This matters for Posit Workbench, since the Workbench session agent reads the same variable to poll kcserver's /status for idle detection (rstudio/rstudio-workbench-vscode-ext#544). Depending on when the agent's terminal is created, it either gets no poller at all, or (worse) it gets the variable and polls the pre-warmed kcserver, which has no sessions. In that second case busy kernels are never counted as activity and nothing is logged, so Workbench can kill a session mid-computation.

Before #14773 the connection file variable was set before kcserver was spawned, so the window/supervisor mismatch couldn't happen.

The natural window is small (I measured ~40-70ms between "Web UI available" and "handshake complete"), so this needs a slow kcserver start (cold container, AV, loaded host). I could only reproduce it by delaying kcserver.

Steps to reproduce the issue:

  1. Delay the pre-warm kcserver spawn in server-main.ts by ~8s (I used a NODE_OPTIONS=--import preload that wraps the spawn in sleep 8)
  2. Start the server and open a window as soon as "Web UI available" prints
  3. Extension host env has no POSITRON_SUPERVISOR_HANDSHAKE_SOCKET; two kcserver processes are running
  4. Start a Python console and run import time; time.sleep(30)
  5. Read the handshake socket from a terminal created after "handshake complete" and query that kcserver's /status: sessions=0 busy=false for the whole sleep

Expected or desired behavior:

Every window should end up on the same supervisor that POSITRON_SUPERVISOR_HANDSHAKE_SOCKET points to. Perhaps extension host startup (or window connections) could wait for the pre-warm to settle, success or failure? Publishing the path earlier doesn't work since the broker treats its first connection as kcserver's report-in.

Were there any error messages in the UI, Output panel, or Developer Tools console?

No. The extension host just starts its own supervisor.

Related: #15896

Dominant language
TypeScript
Stars
4.4k
Forks
207
Avg merge
1d 16h
Merged PRs (30d)
308

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from posit-dev/positron

All issues in posit-dev/positron

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.