Skip to content

[Bug] Windows: the auto-spawned daemon dies with the launching process tree (daemon start / status), and read-only commands start it as a side effect #268

Description

@QIUZAIYOU

Environment

  • OS: Windows 10 22H2 (19045), x64
  • bsk CLI / daemon: 0.2.1 (daemon protocol 1.1), ~/.local/bin/bsk.exe, BSK_HOME=~/.bsk
  • Browser extension: ext-v0.3.0 (reports protocol 1.3)
  • Host: DeepSeek Harness Desktop. Shell commands are invoked with a fixed per-call timeout, stdout captured through a pipe (no TTY); on timeout the harness kills the command's whole process tree.
  • Plugin involved downstream: @wxg-prc-cpg/browser-skill-dsh-plugin 0.2.1

Actual behavior

bsk daemon start never returns in that context. When the harness kills the command at its 120 s timeout, the daemon dies with it — even though bsk daemon start --help says "Start the daemon (auto-detaches unless --foreground)".

bsk status behaves the same way, and it starts a daemon as a side effect: run while no daemon was alive, it printed a complete status block (daemon version 0.2.1, pid 25900, uptime 0s) and then hung; the harness killed it 90 s later — after which that daemon never logged again either.

So a caller that merely checks status can silently remove a healthy daemon. In agent harnesses that is a footgun rather than an edge case, because status / doctor are the first commands an agent runs (#265 and #24 report the unbounded wait; this is the side-effect half of it). The result: an unrelated later browser_session start has to auto-spawn a daemon, hits #180 / #183, hangs forever, and leaves the orphaned Agent Window of #245.

Evidence (~/.bsk/daemon.log.2026-09-17, UTC; local = UTC+8)

Only lines that are actually in the log:

01:12:36  daemon lock acquired; ws server listening 127.0.0.1:52800; daemon ready pid=27604
01:12:36  browser connected id=<ext-instance>
01:12:41  periodic update check failed (github.com unreachable)
01:15:11  daemon ready pid=25900
01:15:11  browser connected id=<ext-instance>
01:17:04  daemon ready pid=18152
01:17:07  browser connected id=<ext-instance>
01:22:34  idle session stopped session=cgya

How to read it (inferences, marked as such):

No daemon exit is logged (no shutdown line, no reason), which is what makes this hard to diagnose from the outside.

Expected behavior (suggested)

  1. Either detach for real, or refuse. If the spawned daemon cannot survive the launcher (DETACHED_PROCESS / CREATE_NEW_PROCESS_GROUP, and on Windows CREATE_BREAKAWAY_FROM_JOB so a job-object kill of the caller cannot take it down), daemon start should fail fast with a message pointing at bsk daemon start --foreground (the pattern docs: clarify remote setup and persistent daemon startup #263 documents for persistent host tasks). The current middle ground — appears detached, then dies silently — is the worst case: the caller has no way to notice.
  2. daemon start should be idempotent and return immediately when a healthy daemon is already running; today it blocks in agent contexts even though the daemon is up.
  3. Read-only commands should not auto-start a daemon (status, doctor, browsers), or should behave as BSK_AUTO_START=0 when stdout is not a TTY. Starting a service as a side effect of a query is what makes agents kill daemons by accident.
  4. Log a reason when the daemon exits (parent-killed / signal / idle). Diagnosing this from timestamps alone cost me a while; a single line would have made it obvious.

Related

Workaround (verified on 0.2.1)

Let the extension/plugin start the daemon (its spawner exits normally, so the daemon survives as an orphan), or start it fully detached:

Start-Process -FilePath "$env:USERPROFILE\.local\bin\bsk.exe" -ArgumentList 'daemon','start' -WindowStyle Hidden

Do not run bsk daemon start / bsk status from a shell tool that kills its process tree on timeout. Read-only liveness probing that never starts anything: bsk browsers, or the owner of TCP port 52800.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions