Skip to content

Android emulator-console calls emu kill, snapshot save and snapshot list have no deadline #1138

Closed

Description

@V3RON

Same shape as #1047, on other paths: these adb -s <serial> emu ... calls go through #processRunner.run / #runOrThrow with no timeoutMs, and NodeProcessRunner sets none by default (src/ports/process-runner.ts:203). An emulator whose console stops answering holds the call, and the device lock with it, without limit (architecture rule 11).

src/drivers/android/index.ts:1217  emu kill        (#stopUnownedEmulator)
src/drivers/android/index.ts:2222  emu avd snapshot save   (#captureBaseline, during makeReady)
src/drivers/android/index.ts:2231  emu avd snapshot list   (#captureBaseline)
src/drivers/android/index.ts:2272  emu kill        (#shutdown, also the fallback #1047 proposes)

Line numbers at ce8fea8. Found while triaging #1047.

Written by an agent.

Activity

  1. added
    bug:new
    on Oct 31, 2026
  2. self-assigned this
    on Oct 31, 2026
  3. added a commit that references this issue on Oct 31, 2026
  4. V3RON commented on Oct 31, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Defect, confirmed for three of the four calls. The #stopUnownedEmulator kill (line 1215 on 6557335) already has timeoutMs: 5_000, asserted by "stops a discovered running emulator before deleting its AVD after a restart".

    Branch bug/1138-repro, src/drivers/android/index.test.ts: "ends a first boot whose emulator console never answers $call: the hung adb call is stopped and makeReady fails" (save, list) / "...and the boot still completes" (kill). Each case hangs one call in the first makeReady and moves the driver clock ten minutes.

    pnpm exec vitest run --project unit src/drivers/android/index.test.ts -t "never answers emu"
    
    -   "hungEnded": true,
    -   "settled": { "error": StringContaining "snapshot save" },
    +   "hungEnded": false,
    +   "settled": "still running",
     ❯ src/drivers/android/index.test.ts:977
    Tests  3 failed
    

    Its ClockDeadlineRunner applies run's timeoutMs on the fake clock, so both fix shapes below pass.

    Root cause

    src/drivers/android/index.ts:2225 (snapshot save) and :2234 (snapshot list) in #captureBaseline call #runOrThrow, and :2275 (emu kill) in #shutdown calls run, all without timeoutMs. NodeProcessRunner.run arms no timer then (src/ports/process-runner.ts:203), so a silent console holds the call, and #withDeviceLock, forever (architecture rule 11). Core shows a device stuck in preparing, reclaiming or destroying; #shutdown is on every stop path.

    Simplest fix

    Pass timeoutMs on the three calls, as lines 1215 and 2078 do: 60 s for save, 5 s (OWNERSHIP_PROBE_TIMEOUT_MS) for list and kill. A scratch version passed the whole file. A timed-out save or list throws the same DriverCrashError as a failed one; a timed-out kill falls through to the existing wait-then-SIGKILL.

    Alternatives rejected

    Risk

    • 60 s must stay above a real snapshot save with a large hw.ramSize on a busy host.
    • After a timed-out kill, #shutdown still waits up to readinessTimeoutMs (180 s) before SIGKILL: bounded, but the lock is held that long.

    Written by an agent.

  5. removed their assignment
    on Oct 31, 2026
  6. added
    bug:ready
    and removed
    bug:new
    on Oct 31, 2026
  7. self-assigned this
    on Oct 31, 2026
  8. V3RON commented on Oct 31, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1159 (#1138)
    Parked: none
    Waiting: none

    Written by an agent.

  9. added a commit that references this issue on Oct 31, 2026
    0ba4794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions