Skip to content

Windows: daemon stop times out after 300 s while the warm pool remakes an Android seed (EBUSY on cache.img) #1700

Open

Description

@V3RON

On Windows, simlock daemon stop failed after 300 s while the warm pool was making an Android seed:

PS> simlock daemon stop
{"error":{"code":"SERVICE_FAILED","message":"The running daemon did not stop within 300 s."}}

The daemon log shows the stop asked at 08:26:07 and the daemon stopping only after the seed make failed, about 300 s later:

{"timestamp":1794990367512,"level":"info","module":"daemon.server","message":"Daemon stopping","fields":{"reason":"requested"}}
{"timestamp":1794990669562,"level":"warn","module":"daemon.warm-pool","message":"warm pool creation of a device failed","fields":{"model":"Pixel 9","step":"provision","error":"Error: EBUSY: resource busy or locked, unlink 'D:\\sv\\spec1071\\devices\\android\\sources\\seed_5008dc0e-62bc-41bc-9231-0678b6f62474\\simlock.avd\\cache.img'"}}
{"timestamp":1794990670759,"level":"info","module":"daemon.server","message":"Daemon stopped","fields":{"reason":"requested"}}

A simlock daemon start 35 s later worked.

How it got there: the worker had been started with ANDROID_HOME=D:\Android\Sdk, then restarted with ANDROID_HOME and ANDROID_SDK_ROOT unset and the SDK found at %LOCALAPPDATA%\Android\Sdk (a junction to the same folder). The warm pool then remade the Pixel 9 / API 35 seed, and the stop came during that make. Two things look wrong:

  1. The stop waited for the seed make. It did not give up on the make or stop its emulator.
  2. Removing the old seed's cache.img failed with EBUSY. A process still had the file open.

Seen on Windows 11 23H2 (DesktopWindows), main at 2df19f8, emulator 37.2.13, while specifying #1692. Not checked on macOS or Linux.

Expected

simlock daemon stop returns within its bound while a seed is being made: the make is cancelled and its emulator stopped. A seed whose files are held open is refused or retried, and does not hold up the stop.

Part of #1068.

Written by an agent.

Activity

  1. added
    bug:new
    os:windows
    platform:android
    on Nov 18, 2026
  2. self-assigned this
    on Nov 19, 2026
  3. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    A gap plus a defect. The first test's expectation is a proposal.

    pnpm exec vitest run --project unit src/core/warm-pool/converger-targets-passes.test.ts src/drivers/android/seeds-copies.test.ts
    
    × aborts a target creation that is running when a drain begins, and ends the drain without waiting for the creation to finish (#1700)
      AssertionError: the running creation was aborted: expected undefined to be true
    × throws the make's own error, not the removal's, when a failed seed's folder cannot be removed (#1700)
      expected [Function] to throw error including 'Android seed seed_two: boot snapshot …' but got 'EBUSY: resource busy or locked, unlin…'
    

    DesktopWindows, dfabcf6, fresh home, Pixel 9 / 35 target, stop during the make:

    {"error":{"code":"SERVICE_FAILED","message":"The running daemon did not stop within 300 s."}}
    === stop returned after 301 s
    === daemon gone after 336 s
    pid=10200 ppid=9948 emulator.exe ...  pid=1532 ppid=10200 qemu-system-x86_64.exe ...
    

    Kill a seed copy's emulator (killChildren: true), then rm its folder:

    no-wait:     rm 12 ms after kill               -> EBUSY ... unlink '...\simlock.avd\cache.img'
    wait-handle: rm after handle.wait(), 244 ms    -> EBUSY ... unlink '...\simlock.avd\cache.img.qcow2'
    qemu gone 491 / 676 ms after kill; rm with maxRetries: 10 then succeeded
    

    The issue's EBUSY was likely the new seed's folder: the old seed is removed when the provision starts, not 300 s in.

    Root cause

    Gap: drain() waits for every running creation (src/core/warm-pool/converger.ts:348), and Driver.provision takes no signal (src/core/driver.ts:301), so nothing cuts a seed make short. A make with its copy took 331 s here; the CLI waits 300 s (src/cli/daemon-service.ts:5). Defect: when a make fails, its cleanup rm (src/drivers/android/seeds.ts:583) throws and replaces the make's error. On Windows it throws because #bootSeedTwice kills the emulator without waiting (seeds.ts:605), and the qemu child holds the disks about 0.5 s longer.

    Simplest fix

    Tried, then discarded:

    1. WarmPool.close() aborts an AbortController; #provision passes its signal through DeviceProvisioner.provision to driver.provision(spec, { source?, signal? }). Shape pinned: a signal on the provision options.
    2. #makeSeed's catch keeps the make's error when the removal fails; the making row stays for the sweep.
    pnpm exec vitest run --project unit src/core/warm-pool/ src/drivers/android/seeds-copies.test.ts src/drivers/android/seeds.test.ts src/core/device-provisioner*.test.ts src/daemon/main-stop.test.ts
          Tests  282 passed (282)
    pnpm typecheck   # clean
    pnpm test:changed
          Tests  5904 passed | 2 skipped (5906)
    

    Not tried: Android honouring the signal (end Emulator.start's wait, kill and wait for the seed emulator), and maxRetries on NodeFilesystem.rm (src/ports/filesystem.ts:356).

    Alternatives rejected

    Risk

    • The warm-pool manual's rule "drain() finishes running boots" changes.
    • A request waiting on the creation's boot claim sees it fail at stop.
    • A lease request's own seed make still holds a stop.

    Fast track

    • Defect: no — a gap: provisioning cannot be cancelled
    • Fix tried: no — the Android driver's abort was not tried
    • Nothing public added or broken: yes
    • No ADR or rule changed: no — the warm-pool manual's drain rule changes
    • One fix: no — two changes, and which stops cancel is a choice

    Written by an agent.

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

    @V3RON
    ContributorAuthor

    Maintainer decisions on the triage report (2026-11-19):

    1. daemon stop cancels a warm-pool seed make and stops its emulator. This needs cancellable provisioning and changes the warm-pool manual's rule that drain() lets running boots finish, so it goes through a spec session first.
    2. A lease request's own seed make: unchanged, stop still waits for it (Stopping the daemon during a pending Android lease leaves an adb server on port 5038, so Android is unavailable after restart #1200).
    3. The EBUSY cleanup fix ships on its own first: split out as Windows: a failed Android seed make's cleanup throws EBUSY and hides the make's error #1765.

    Written by an agent.

  6. added
    request:new
    and removed
    bug:new
    on Nov 20, 2026
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

    os:windowsplatform:androidrequest:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions