Skip to content

iOS: a clone whose mark or swap fails is deleted once, and a delete that times out or fails is dropped silently #1802

Open

Description

@V3RON

A provision whose simctl clone succeeded but whose mark write, LaunchServices drop or lineage swap then fails deletes the clone once and drops every outcome of that delete:

src/drivers/ios/seeds.ts:249:

await this.#simctl.invoke(["delete", udid], COMMAND_TIMEOUT_MS).catch(() => undefined);

invoke answers a time-out or a non-zero exit as an outcome rather than throwing, so .catch only covers a spawn failure. A delete that times out (30 s) or exits non-zero is neither retried nor logged. The clone has no registry record, so it is left as an orphan-device (deviceSet: "simlock") or, under deviceSet: "default", as an unmarked simulator that listManaged never lists and nothing deletes (the end state #1546 fixed for a late clone). The request fails, and after a second failure is rejected unresolvable-spec, with no line naming the UDID left behind.

Expected: a failed delete is at least logged with the UDID, as deleteLateSimulator does for a late clone.

Found while triaging #1801.

Written by an agent.

Activity

  1. added
    bug:newReported. An agent may triage it (rule 8); the fast track may set it ready (rule 17).
    on Nov 22, 2026
  2. self-assigned this
    on Nov 22, 2026
  3. V3RON commented on Nov 22, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed. src/drivers/ios/index-seed-sources.test.ts, "a clone whose LaunchServices drop fails and whose delete then exits non-zero or times out is logged with its UDID" (branch bug/1802-repro). Cases: a delete that works (no warning), one that exits 1, one that times out.

    pnpm exec vitest run --project unit src/drivers/ios/index-seed-sources.test.ts -t "is logged with its UDID"
    
    AssertionError: a delete that exits non-zero: expected [] to deeply equal [ Array(1) ]
    - "could not delete simulator 00000000-0000-0000-0000-000000000001 after a failed provision: simctl delete 00000000-0000-0000-0000-000000000001 exited with code 1: Unable to delete"
    + []
    

    Root cause

    Defect. src/drivers/ios/seeds.ts:249 calls this.#simctl.invoke(["delete", udid], ...), which returns a time-out or a non-zero exit as an outcome and never throws for them; the result is discarded and .catch(() => undefined) covers only a spawn failure. The comment above it says the clone must not be left behind, yet a failed delete leaves it with no trace. The late-clone path (command-run.ts:80-86) logs the same failure.

    Simplest fix

    Delete through #deleteIn(udid, undefined) (checks the outcome, treats Invalid device as gone) inside a try, and this.#logger?.warn(could not delete simulator ${udid} after a failed provision: ${errorMessage(deleteError)}) on failure; rethrow the original error.

    pnpm exec vitest run --project unit src/drivers/ios   # with the fix
    Test Files  34 passed (34)
         Tests  766 passed | 1 skipped (767)
    

    Alternatives rejected

    • Retry the delete: a timed-out simctl delete may still be running, and the late-clone path does not retry.
    • Keep a registry record for the clone so doctor lists it: new state for a rare failure.

    Risk

    • The test asserts an undocumented log line; testing rule 8 tests only documented ones (same file already does at line 88).
    • An already-gone clone (Invalid device) now logs nothing; check that is wanted.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: no — the regression test asserts an undocumented log line (testing rule 8)
    • One fix: no — a retry would leave fewer simulators behind

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 22, 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

    bug:newReported. An agent may triage it (rule 8); the fast track may set it ready (rule 17).

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions