Skip to content

Fix slow kernel startup on Windows with antivirus software#14773

Open
jmcphers wants to merge 4 commits into
mainfrom
feature/supervisor-connection-no-file
Open

Fix slow kernel startup on Windows with antivirus software#14773
jmcphers wants to merge 4 commits into
mainfrom
feature/supervisor-connection-no-file

Conversation

@jmcphers

@jmcphers jmcphers commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #13388

Summary

The goal of this change is primarily to address some pathological slow-boot problems observed in Windows corporate environments with aggressive AV software. It also increases the security and performance of the kernel supervisor subsystem for everyone.

To do this, it replaces the connection-file handshake between Positron and the Kallichore kernel supervisor (kcserver) with a same-user-locked handshake socket, eliminating the temp file entirely.

Previously, Positron picked a temp path, launched kcserver with --connection-file <path>, and polled the filesystem until kcserver wrote the connection details (transport, address, bearer token) there. On Windows with aggressive antivirus, the freshly-written file could be invisible to Positron for up to ~32s while it was held for scanning, and the bearer token -- which gates an API that runs arbitrary code as the launching user -- sat on disk protected only by file permissions.

This inverts the handoff. Positron now creates and listens on a handshake socket (Unix domain socket / Windows named pipe) first, launches kcserver with --handshake-socket <path>, and kcserver connects once and writes a single JSON payload (the same KallichoreServerState shape as the old connection file), then closes. No file at rest for AV to scan, no polling race, and the token travels over an OS-protected same-user socket instead of disk.

Two launch paths are handled:

  • Desktop: the extension host both launches kcserver and connects to it, so it hosts the handshake socket directly (extensions/positron-supervisor/src/HandshakeSocket.ts).
  • Web/server: kcserver is pre-warmed by the long-lived server process before any window exists, so src/server-supervisor-handshake.ts acts as an in-memory broker -- it receives kcserver's payload, caches it, and re-serves it to each window's extension host over the socket. Only the socket path crosses the env boundary (POSITRON_SUPERVISOR_HANDSHAKE_SOCKET, renamed from POSITRON_SUPERVISOR_CONNECTION_FILE); the token stays in memory.

Note

This represents a breaking change in the way that we connect to Kallichore and requires the accompanying Kallichore PR for testing. Build posit-dev/kallichore#73 alongside this change for testing.

Release Notes

New Features

  • N/A

Bug Fixes

Validation Steps

This change is on the critical path for every kernel session, so the existing e2e suite exercises it end to end on each run across platforms. No new user-visible behavior is introduced; the coverage story is unit tests for the new helper + broker, plus the existing suite as cross-platform regression coverage.

Unit tests:

  • npm run test-extension -- -l positron-supervisor --grep HandshakeSocket (desktop path)
  • npx vitest run src/server-supervisor-handshake.vitest.ts (server broker)

E2e regression (existing tags -- supervisor startup is implicit in all of these):

@:console @:sessions @:interpreter

Manual checks worth doing before merge, since they're hard to assert in CI:

  1. Windows: start R and Python kernels; confirm sessions come up promptly with no connection-file temp path in the logs (named-pipe handshake path).
  2. Web/server mode: start Positron in server mode and open a window; confirm a kernel starts (broker re-serves the cached payload to the extension host). Open a second window and confirm it connects too.
  3. Confirm no kallichore-*.json connection file is created in the temp dir during startup.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:console @:sessions @:interpreter

readme  valid tags  why these tags?

@jmcphers jmcphers changed the title Feature/supervisor connection no file Fix slow kernel startup on Windows with antivirus software Jul 8, 2026
@jmcphers jmcphers requested a review from samclark2015 July 8, 2026 19:27

@samclark2015 samclark2015 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Manually verified:

  • Launched Positron against Kallichore paired PR
  • Ensured the new handshake socket route was used
  • Ensured sessions persisted across relaunches of Positron
  • Ensured new handshake path worked also on a server build

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.

Supervisor: Pass startup connection information without a connection file

2 participants