Skip to content

nuke --delete-devices skips a device stalled in provisioning, so it holds a capacity slot forever #1487

Closed

Description

@chidev

What happened

An Android device stayed in provisioning for 6 days on a gateway worker. No emulator process ran for it, and its AVD files were not on disk. It took one of the worker's Android maxDevices slots (Capacity android: managed 1/2).

simlock doctor reported it:

{"findings":[{"kind":"stalled-transition","deviceId":"dev_3560ab4a-…","platform":"android","state":"provisioning","ageMs":529506806,"thresholdMs":213000}]}

None of these cleared it:

  • simlock cleanup (dry run listed nothing)
  • simlock nuke --delete-devices --yes returned {"deletedDevices":[],"releasedLeaseIds":[]}
  • a worker daemon restart

What you expected

nuke --delete-devices (or startup recovery) deletes a stalled provisioning device, or doctor names a command that does.

Cause (from reading the source)

NukeService.#resetDevice (src/core/nuke-service.ts, about line 176 on main) destroys a device only through #currentShutdown, which returns a device only in state shutdown. A device in provisioning is skipped. ManagedDeviceLifecycle.destroy already accepts ["provisioning", "shutdown"], so passing a stalled provisioning device to it looks like the fix.

How to reproduce

  1. Run a worker joined to a gateway. Android capacity: fixed, maxRunning 1, maxDevices 2.
  2. Start an Android lease and break it while the device is provisioning. In our case the emulator binary (35.5.10) rejected -crash-report-mode, and the emulator was then updated.
  3. The device stays provisioning. Run simlock nuke --delete-devices --yes: the device is not deleted.

Workaround we used

We stopped the worker, backed up state.db, and set that one row to state='deleted'. Then we started the worker again. After that, doctor reported no findings, and a new Android lease booted in 55 s.

Environment

  • Simlock 0.5.0 (CLI and daemon), gateway on one Mac with a worker on another
  • Worker: macOS 15.7.1 arm64 (M4 Max), Xcode 26.3, emulator 37.2.13, platform-tools 35.0.2
  • Pixel 9, Android 36 image

Logs and evidence

The doctor output and the nuke result are quoted above. The worker's daemon.log has no line for the device id.

Activity

  1. added
    bug:new
    platform:android
    on Nov 10, 2026
  2. assigned and unassigned on Nov 10, 2026
  3. V3RON commented on Nov 10, 2026

    @V3RON
    Contributor

    Reproduction

    Defect, confirmed as the reporter read it. src/core/nuke.test.ts, "with delete, deletes a device an earlier process left provisioning, reports it, and frees its slot for the next lease" (on bug/1487-repro). It registers an Android device that stays provisioning with no claim, the state a restart leaves, at maxDevices: 1. Then it runs nuke with delete and asks for a lease.

    pnpm exec vitest run --project unit src/core/nuke.test.ts
    
    AssertionError: expected 'provisioning' to be 'deleted'
     ❯ src/core/nuke.test.ts:127:89
    

    Root cause

    src/core/nuke-service.ts:195: #currentShutdown returns a device only in state shutdown, and #resetDevice (line 182) destroys only what it returns. A provisioning device that nothing claims is skipped, though ManagedDeviceLifecycle.destroy accepts provisioning (managed-device-lifecycle.ts:196). This breaks the user docs, which say --delete-devices deletes every device Simlock created (worker/cleanup.mdx:116). Every in-flight provision holds a boot claim, and the lifecycle's own claim refuses a claimed device, so a live provision stays safe.

    Simplest fix

    Let #currentShutdown accept provisioning as well as shutdown, and let #canOperate check that state. Update the Nuke line in src/core/AGENTS.md ("destroy each shutdown or unclaimed provisioning one").

    pnpm exec vitest run --project unit src/core/nuke.test.ts src/core/nuke-service.test.ts
    Tests  15 passed (15)
    

    Alternatives rejected

    • Startup deletes unclaimed provisioning devices: it leaves nuke breaking its docs, and doctor --fix already handles stalls.
    • Quarantine a provisioning device in nuke: the docs say nuke deletes it.

    Risk

    • On Android, destroy of a device whose AVD folder is gone must not throw (drivers/android/index.ts:670), or nuke logs the error and skips it again. The test uses the fake driver.
    • Until the fix ships, simlock doctor --fix quarantines the stalled device, and the retry deletes it (worker/troubleshooting.mdx:57).

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 10, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 10, 2026
  6. self-assigned this
    on Nov 10, 2026
  7. V3RON commented on Nov 10, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1518 (#1487)
    Parked: none
    Waiting: none
    Decided: none

    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

Labels

bug:readyfast-trackplatform:android

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions