[Bug] Windows: session create always fails — worker handshake budgets cannot accommodate AV-slowed process launches #1678
Replies: 1 comment
|
Independent reproduction, on a machine with no AV/EDR involvement — which I think widens the scope of this report usefully. Same failure, same two stages, Windows 11 (10.0.26200) / Node 24.12 / prime-agent 0.7.4. In my case the trigger was simply a heavily loaded box (~150 concurrent node/python processes, 60% CPU), not real-time scanning. So the budgets are under-provisioned for any source of contention, not just AV. Measured here with temporary instrumentation inside the worker's
That 1.20s against a 1000ms budget is the whole bug: it fails just over the line, which is why it presents as flaky alternation between The instrumentation trace, showing the loop never converging: Note the worker succeeds every time and writes its success response — the supervisor has simply already abandoned that attempt. So the retry loop in Two negative results that may save someone time:
Patch I am running, matching @ysquare's conclusion — two constants,
Result: On regression risk — I have this on a branch and opened it as a PR before reading CONTRIBUTING.md properly — it was correctly auto-closed as unvouched (#2013), so I am adding it here instead. Happy to leave it at that, or hand the branch over if a maintainer wants it; entirely up to you. A design thought for whoever picks this up: raising the constants fixes the symptom, but 🤖 Generated with Claude Code |
Uh oh!
There was an error while loading. Please reload this page.
Affected area
TUI
What happened?
Any launch that needs a new session worker fails after 30 s with:
The daemon log shows the supervisor's retry loop dying at either stage:
On this machine each
worker_authtakes 2.2–3.4 s of synchronous work (a PowerShell spawn inside the supervisor-claim check), while the per-attempt budgets are 1000 ms each — so the handshake can never succeed.Steps to reproduce
prime-agent -p "Reply with exactly: OK".createtimeout above; the daemon log shows the hello/worker_auth timeout loop.Expected behavior
Session creation succeeds on machines where process launch + PowerShell startup take a few seconds — the handshake budgets should tolerate the measured per-attempt cost.
Prime Agent version
0.8.0
Environment
Additional context
DaemonSupervisor.connectWorker(src/modes/daemon/daemon-supervisor.ts) allows 1000 ms per attempt for hello and 1000 ms forworker_auth, inside a 30 s window (WORKER_CONNECT_TIMEOUT_MS);DaemonClient.request(src/modes/daemon/daemon-client.ts) defaults to 30 s forcreate. On an AV-scanned machine:worker_authrunsassertSupervisorClaimCurrent→assertDaemonSupervisorOwnerCurrent(src/modes/daemon/daemon-supervisor-ownership.ts) →isProcessIdentityAlive→getProcessStartId, which synchronously spawnspowershell.exe(2–4 s under AV) and blocks the worker's event loop while it runs.With temporary instrumentation we measured
worker_auth received → claim okat 2.2–3.4 s per attempt. Widening the budgets locally fixed everything:waitForHelloper attemptauthenticateWorkerper attemptWORKER_CONNECT_TIMEOUT_MSDaemonClient.requestdefaultTwo structural notes beyond the numbers:
getWindowsProcessStartIdblocks the worker's event loop for seconds per auth attempt. Caching the supervisor's start-id (it cannot change during the life of the process) or computing it once at startup would remove most of the pressure.connectWorker's retry loop opens a fresh connection every ~25 ms during the window, and each fresh connection re-runs the PowerShell identity check on the worker — so a slow machine multiplies the very work that makes it slow.Happy to turn the timeout widening (or the start-id caching) into a PR.
All reactions