Skip to content

Windows 0.9.0: conhost --headless exits at once when stdin is "ignore", so the adb server (and emulators) never start #1920

Done

Description

@floklein

On a Windows worker, 0.9.0 never starts its adb server, so the Android driver is skipped and the worker offers no Android devices. It worked on the same machine with 0.8.0.

"module":"daemon.driver-discovery","message":"Skipped Android driver: adb server unavailable",
"fields":{"port":5038,"reason":"start-failed","summary":"Refusing to run the android driver: Simlock's adb server did not start listening on port 5038 within 10000ms"}

simlock catalog then prints No platforms available., and ~\.simlock\logs\adb-server.log holds only conhost's title escape sequence (ESC]0;C:\Windows\System32\conhost.exe).

Seen on Windows 11 (Windows_NT 10.0.26300 x64), Simlock 0.9.0, agent-device 0.21.44, SDK platform-tools 37.0.0, emulator 36.5.11, worker started by the logon scheduled task (simlock daemon start) and joined to a gateway.

Why

A child with outlivesCaller: true is wrapped by headlessLaunch (dist/ports/windows-command.js) as conhost.exe --headless <command> ...args (ADR 0086, #1759). A child that logs to a file gets stdio: ["ignore", logFd, logFd] (childStdio in dist/ports/node-process-runner.js). With stdin set to ignore, conhost.exe --headless exits immediately (exit 0) without ever starting the program it was given. The adb server is launched this way, so it never listens, and the driver gives up after 10 s.

The emulator is launched the same way (dist/drivers/android/emulator.js, outlivesCaller: true, stdio: { file: logPath }), so fixing only the adb launch would move the failure to emulator boot.

Reproduction

Node child_process.spawn with the same options Simlock uses:

  • conhost.exe --headless <sdk>\platform-tools\adb.exe -P 5038 nodaemon server, stdio: ["ignore", fd, fd]: exits 0 after ~31 ms, nothing listens on 5038, and the log holds only the conhost escape sequence (byte for byte what the worker's adb-server.log holds).
  • Same adb, spawned directly with the same stdio: listening on 127.0.0.1:5038 after ~112 ms.
  • conhost.exe --headless cmd.exe /c "echo hi && ping -n 2 127.0.0.1": with stdin ignore, exits 0 after ~23 ms with no output; with stdin pipe, runs ~1 s and prints hi.

Port 5038 was free and in no excluded port range; another (unrelated) adb server on 5037 plays no part.

Possible fix

Give the wrapped child a stdin that stays open (for example "pipe", left unwritten) whenever headlessLaunch applies, or skip the conhost wrapper for children that log to a file.

Activity

  1. added
    bug:new
    on Nov 27, 2026
  2. self-assigned this
    on Nov 28, 2026
  3. V3RON commented on Nov 28, 2026

    @V3RON
    Contributor

    Reproduction

    Confirmed in-process: on Windows, a child spawned with outlivesCaller: true and stdio: { file } (the adb server and every emulator) runs as conhost.exe --headless ... with stdin "ignore". The reporter's Windows measurements show that this stdin makes conhost exit before it starts the program. I did not rerun those on Windows.

    src/ports/child-window.test.ts, "a child under conhost --headless that logs to a file gets a stdin that stays open", on branch bug/1920-repro. It sets the platform and checks the stdio handed to spawn. The two win32 cases fail. The win32 short-lived case and the darwin and linux cases (stdin stays "ignore") pass.

    pnpm exec vitest run --project unit src/ports/child-window.test.ts
    × on win32, the adb server's options give stdin pipe
    × on win32, an emulator's options give stdin pipe
    -       "pipe",
    +       "ignore",
    +       13,
    +       13,
    Tests  2 failed | 14 passed (16)
    

    Root cause

    Defect. src/ports/node-process-runner.ts:595 (childStdio) returns ["ignore", logFd, logFd] for every file-logged child. It does not account for the conhost wrapper that launchOf (line 588) adds through headlessLaunch (src/ports/windows-command.ts) since #1766. Node's "ignore" hands the child the NUL device. conhost reads that as console input that has already ended, so it exits with code 0 and never launches adb or the emulator. The symptom shows later: adb-server.ts gives up after 10 s with start-failed.

    Simplest fix

    childStdio takes a headless flag (the wrapper was applied: outlivesCaller on win32). When the flag is set it returns ["pipe", logFd, logFd] and nothing ever writes to that pipe.

    reproduction: 16 passed; src/ports/: 38 files, 443 passed;
    adb-server/emulator tests: 29 passed; pnpm typecheck: clean
    

    Alternatives rejected

    Risk

    • Not verified on Windows: does the daemon's exit end the pipe and stop conhost, ending emulators that must outlive the daemon (ADR 0004, 0019)? Check this with a daemon restart on a Windows worker.
    • The pipe handle stays referenced after handle.unref(). This is harmless in the long-lived daemon.

    Fast track

    Written by an agent.

  4. removed their assignment
    on Nov 28, 2026
  5. V3RON commented on Nov 30, 2026

    @V3RON
    Contributor

    Maintainer decision on the triage report (2026-11-30):

    Approved as proposed: a file-logged child under conhost --headless gets an open, unused stdin pipe.

    Before merge, prove it on a Windows PC: adb and an emulator start, and both survive a daemon restart. If the restart ends them, stop and report. Do not fall back to dropping conhost without a new decision, because that brings back #1759's window.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 30, 2026
  7. self-assigned this
    on Nov 30, 2026
  8. V3RON commented on Nov 30, 2026

    @V3RON
    Contributor

    Handoff

    Done: PR #1958 (draft) at c23782e: the approved stdin pipe and its test. Audited. Review round 1 ran all three lenses.

    Not done: the Windows check, the fixes, round 2, the gate. ssh DesktopWindows timed out on every try; Tailscale says offline for 4 days.

    Findings:

    • R1, node-process-runner.ts:600: only the daemon holds the pipe's write end, so its exit gives conhost EOF. A macOS stand-in saw that EOF. Whether real conhost then ends adb and the emulator is unmeasured.
    • R2, child-window.test.ts:161: the title says stdin stays open; the test checks only the spawn option.
    • E2E (2/3) red: physical-devices-core.test.ts:461. Cause not found. The stdio change is win32-only; main was green.

    Blocked on: the Windows PC online, then a daemon restart with adb and an emulator running. If they die, R1 is real and needs a maintainer decision.

    Written by an agent.

  9. added
    bug:blocked
    and removed
    bug:ready
    on Nov 30, 2026
  10. removed their assignment
    on Nov 30, 2026
  11. V3RON commented on Nov 30, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1920 — the Windows PC is offline, so the check that must pass before merge has not run (PR #1958, draft)

    Written by an agent.

  12. added
    bug:ready
    and removed
    bug:blocked
    on Nov 30, 2026
  13. 26 remaining items

  14. V3RON commented on Dec 2, 2026

    @V3RON
    Contributor

    Handoff

    Done: PR #1958 (draft, 7d21557). On the Windows PC with win-smoke booted: adb, the emulator and their conhosts survived their starter's exit, a hard kill of the starter, and a real simlock daemon stop. A second spawn after a first conhost child was writing returned in 4–6 ms (4 runs). R4 and R5 fixed. #1965 did not reproduce in ~340 runs, with the pair on or off.

    Not done: the gate.

    Findings: R3 (a second spawn could hang on the shared stdin) stays blocking past the fix-check cap. The review is blind to the PC probes. It asks for a Windows run of windows-command.test.ts:343 at 7d21557. The CI windows-unit shards at that head give that run.

    Blocked on: the maintainer. Read the windows-unit log at 7d21557 for the test at :343. If it passes, rerun with --restart. Main's red Windows jobs are a separate bug.

    Written by an agent.

  15. added
    bug:blocked
    and removed
    bug:ready
    on Dec 2, 2026
  16. removed their assignment
    on Dec 2, 2026
  17. V3RON commented on Dec 2, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1920 — R3 (second spawn on the shared stdin) still blocking past the fix-check cap; the PC probes passed, and the review waits for a Windows run of windows-command.test.ts:343 at 7d21557 (PR #1958, draft)
    Decided: #1920 — the cause of the R3/#1965 timeout was not found on the PC → go on to review; nothing ties it to this change

    Written by an agent.

  18. added
    bug:ready
    and removed
    bug:blocked
    on Dec 2, 2026
  19. self-assigned this
    on Dec 2, 2026
  20. V3RON commented on Dec 2, 2026

    @V3RON
    Contributor

    Handoff

    Done: PR #1958 is ready at 317cc9b, a merge of main with no change to the PR's own diff. The fix-check closed R3 as incorrect. In CI run 46859593706 at 7d21557, "Unit tests (Windows) (3/3)" passed windows-command.test.ts 29/29, including the second-child test (4451 ms). The PC probe also showed a second spawn returning in 4–6 ms. All five findings are closed and the review ledger is posted.

    Not done: the merge.

    Findings: none open. "Unit tests (Windows) (1/3)" and Quality fail only because of main's bug #2027 (draft PR #2032), not this PR.

    Blocked on: the fast track's held: line, "its reporter floklein cannot write to the repo, so the maintainer merges PR #1958". The maintainer merges the PR by hand once #2032 lands, or now if main's red is accepted.

    Written by an agent.

  21. added
    bug:blocked
    and removed
    bug:ready
    on Dec 2, 2026
  22. removed their assignment
    on Dec 2, 2026
  23. V3RON commented on Dec 2, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1920 — held by the fast track: an outside reporter, so the maintainer merges PR #1958 (ready, R3 closed on Windows CI evidence)

    Written by an agent.

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

    bug:blockedos:windowsplatform:android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions