Skip to content

iOS: simctl clone and create are cut off at a fixed 30 s, and under deviceSet "default" each cut-off clone leaves a simulator nothing can delete #1546

Description

@dpearson2699

What happened

On a Mac under heavy load, simctl clone regularly takes longer than 30 s. Simlock cuts every simctl call off at a fixed 30 s, so on that Mac:

  • Four warm-pool creations failed at the limit:
    warm pool creation of a device failed … step: provision … DriverCrashError: simctl clone <seed udid> simlock-<id> ~/Library/Developer/CoreSimulator/Devices timed out after 30000ms
  • Four of five simlock baseline save calls failed the same way (BASELINE_SAVE_FAILED … simctl clone <device udid> simlock-baseline-<id> … timed out after 30000ms, each after 33 to 34 s).
  • Under drivers.ios.deviceSet: "default", every creation that failed this way left one simlock-<id> simulator in Xcode's device set. The copy finished after Simlock had stopped waiting, so the simulator has no mark and no registry record. simlock nuke --delete-devices --yes and simlock doctor --purge-orphans did not remove them. Five were left (about 6.3 GB) and had to be deleted by hand with xcrun simctl delete <udid>.

The limit is a constant, so no setting makes these copies succeed.

Cause, at d30c24d8 (the same lines are in v0.7.0):

  1. src/drivers/ios/index.ts:108: const COMMAND_TIMEOUT_MS = 30_000; is the limit of every simctl call, including the three that copy or create a whole simulator: the clone in provision (index.ts:933-938), the clone in saveSource (index.ts:851-854) and the create in #makeSeed (index.ts:1036-1045). ios.full.bootTimeoutMs and ios.slim.bootTimeoutMs cover the boot wait only.
  2. #invokeCommand (index.ts:2060-2095) sends SIGTERM to xcrun simctl at the limit. The copy itself is done by CoreSimulator's service, which carries on, so the simulator still appears, after the driver has thrown with no UDID in hand.
  3. In provision the mark is written only once clone has answered (index.ts:940-947), and the delete-on-failure there (index.ts:949-953) needs that UDID. Under default, listManaged reports only simulators whose durable mark names this instance (index.ts:1539-1553), so the late simulator is never listed, never an orphan and never deleted. It is the end state src/drivers/ios/AGENTS.md lists as a known gap for a restart between simctl clone and the mark (iOS simulators can live in Xcode's device set (drivers.ios.deviceSet) #968), reached here with no restart.

Under deviceSet: "simlock", and for a seed or a baseline (both live in the sources set), the same timeout leaves a simulator in a Simlock-owned set, which doctor --purge-orphans can still reach. The creation still fails.

What you expected

  • A setting for how long a simctl clone or simctl create may take, as ios.full.bootTimeoutMs is for a boot, with today's 30 s as its default.
  • A creation that fails or runs out of time never leaves a simulator that Simlock cannot find and delete, under default as well.

A possible fix (I am preparing it on a fork and will link a draft pull request here; close it if that is not welcome):

  • A driver key, for example ios.simulator.createTimeoutMs (positive number, default 30000), read by the three calls in point 1. Every other simctl call keeps 30 s.
  • At that limit the driver stops waiting but does not kill simctl clone / simctl create. When the command later prints its UDID, the driver deletes that simulator. The UDID comes from the driver's own call, so ownership is proven the same way as in the existing delete after a failed mark write, with no reliance on the simlock- name (safety rule 8). The late copy keeps the seed's turn until it ends, so the seed is not deleted under it. A command still silent after a second, fixed limit is killed and logged with the name it was asked to create.

How to reproduce

  1. On a Mac, set drivers.ios.deviceSet to "default" and ios.defaultMode to "slim" in config.json, and start the daemon.
  2. Put the Mac under heavy CPU and disk load (here: other builds and simulator test runs on the same Mac; load average 300 to 900 on 16 cores).
  3. simlock lease --platform ios, or let the warm pool create a device, a few times.
  4. Requests fail with simctl clone … timed out after 30000ms.
  5. xcrun simctl list devices | grep simlock- then shows simulators that simlock status does not list, and simlock doctor --purge-orphans and simlock nuke --delete-devices --yes leave in place.

Here it happened on most creations while the load lasted (4 of 4 warm-pool creations, 4 of 5 baseline saves). On an idle Mac the same clone takes a few seconds and nothing fails.

Environment

  • Simlock 0.7.0 (npm), worker mode
  • iOS simulators, iOS 27.0 runtime, slim mode
  • macOS 27.2.1, Xcode 27.2 (27B52), Apple silicon, 16 cores, 48 GB
  • drivers.ios.deviceSet: "default"

Logs and evidence

From daemon.log, with folders shortened and names replaced by placeholders:

warn daemon.warm-pool "warm pool creation of a device failed" model="iPhone 18 Pro Max" step="provision"
  error="DriverCrashError: simctl clone <seed udid> simlock-<id> ~/Library/Developer/CoreSimulator/Devices timed out after 30000ms"

info daemon.server.dispatch operation="baseline.save" durationMs=34150 code="BASELINE_SAVE_FAILED"
  message="baseline <name> was not saved: simctl clone <device udid> simlock-baseline-<id> <simlock home>/devices/ios-sources timed out after 30000ms"

No existing issue covers this: #1248 / #1315 made the boot wait configurable and left the 30 s simctl limit out of scope, and #968's known gap is the restart case.

Activity

  1. dpearson2699 commented on Nov 13, 2026

    @dpearson2699
    Author

    Draft fix from a fork: #1547 (ios.simulator.createTimeoutMs, and a create or clone that answers after it is deleted instead of left behind).

    Written by an agent.

  2. dpearson2699 commented on Nov 13, 2026

    @dpearson2699
    Author

    One more measurement from the same Mac, with #1547's first commit (the limit raised for create and clone only) and a load average near 1000: a baseline save whose clone took 53 s now succeeded, but the next lease failed after 35 s with BootTimeoutError, and the destroy that followed failed with simctl shutdown <udid> timed out after 30000ms. So simctl boot and simctl shutdown pass the same fixed 30 s there (src/drivers/ios/index.ts:1253, :1263 and :1994 at d30c24d8). #1547 now gives create, clone, boot, shutdown and delete one key, ios.simulator.lifecycleTimeoutMs, instead of the ios.simulator.createTimeoutMs named above.

    Written by an agent.

  3. added a commit that references this issue on Nov 14, 2026
  4. added
    bug:new
    on Nov 15, 2026
  5. self-assigned this
    on Nov 15, 2026
  6. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Reproduction

    Branch bug/1546-repro, src/drivers/ios/index.test.ts. The first test is a proposal: its key name is Simplest fix's.

    pnpm exec vitest run --project unit src/drivers/ios/index.test.ts -t "createTimeoutMs|answers after its limit"
    
    × a provision's clone / a seed's create / a baseline's clone waits ios.simulator.createTimeoutMs
      AssertionError: expected 'rejected' to be 'pending'      (at 119 999 ms of a 120 000 ms limit)
    × under deviceSet default a provision whose clone answers after its limit deletes the simulator the clone names
      AssertionError: expected [] to deeply equal [ [ 'simctl', 'delete', '…00c1' ] ]
    

    Root cause

    A gap with a defect inside it. Gap: src/drivers/ios/index.ts:108 (COMMAND_TIMEOUT_MS) is the only limit on the clone in provision (:936), the clone in saveSource (:853) and the create in #makeSeed (:1043), and no key changes it. Defect: at the limit #invokeCommand (:2066-2073) kills simctl, but the copy still finishes. The delete in provision (:949-953) needs a UDID that the killed command never printed. Under default, listManaged (:1539) lists only marked simulators, so nothing can reach the copy. This breaks architecture rule 11: a caller that times out must leave the far side no worse off. The issue's points 1 to 3 hold.

    Simplest fix

    Gap, proposed shape: ios.simulator.createTimeoutMs (positive number, default 30000) in definition.ts, read by the three calls. Defect: at that limit the call rejects but does not kill. The command keeps the seed's turn. When it answers late with a UDID, that simulator is deleted in the set it landed in. A second fixed limit kills it and logs.

    trial (~80 lines in index.ts and definition.ts, then restored):
    pnpm exec vitest run --project unit src/drivers/ios/ src/daemon/driver-discovery.test.ts
      the 4 reproductions pass; 8 neighbour tests fail on their old expectations:
      definition.test.ts (4) and driver-discovery.test.ts (1): the defaults now hold createTimeoutMs
      "provisions a copy of the kind's seed…", saveSource "keeps a shut-down copy…": spawn timeoutMs 30000 -> 630000
      "two provisions at once make one seed…": the second clone waits for the first, late clone
    

    Alternatives rejected

    Risk

    • Deleting seeds (nuke, removeComponent) waits behind a late clone, up to the second limit.
    • The late delete under default acts on an unmarked UDID. It is proven only by the driver's own call, as in the failed-mark delete (safety rules 1 and 8).
    • Docs: the configuration pages on the website gain the key.

    Fast track

    Side findings

    Written by an agent.

  7. removed their assignment
    on Nov 15, 2026
  8. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Decision

    The maintainer chose the narrow key: drivers.ios.simulator.createTimeoutMs (positive number, default 30000), read only by the three calls that copy or create a whole simulator: the clone in provision, the clone in saveSource and the create in #makeSeed. Every other simctl call (boot, shutdown, delete and the rest) keeps the fixed 30 s; simctl boot is #1560, not this fix. The lifecycle-wide key of #1547 is not taken.

    Tests: the triage's $call waits ios.simulator.createTimeoutMs table (provision clone, seed create, baseline clone stay pending at 119 999 ms of a 120 000 ms limit), and under deviceSet default a provision whose clone answers after its limit deletes the simulator the clone names, on bug/1546-repro (d1eb61ef).

    Written by an agent.

  9. added
    bug:ready
    and removed
    bug:new
    on Nov 15, 2026
  10. self-assigned this
    on Nov 15, 2026
  11. 12 remaining items

  12. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Handoff

    Done

    #1563 (ready, head a5af2d14) passed review: round 1, round 2 and three fix-checks, the last two approved by the maintainer past the cap. R1, R2, R5 and R6 are fixed, R7 is rejected as nonblocking, and the review ledger is posted. The Fallow constructor complexity failure is fixed by extraction, which the review coordinator verified.

    Not done

    Not merged. The gate's second run refused: not merged: CI not green on PR #1563: fail Quality;fail Unit tests;.

    Findings

    src/source-hygiene.test.ts "fails a listed file that grew past its listed length" (CI run 43721811488, classified reach). The extraction in a5af2d14 added 5 net lines to src/drivers/ios/index.ts, which was at 2696 against its listed 2700.

    Blocked on

    Red CI a second time at the gate parks the PR. The maintainer decides: one fix run that brings index.ts back under 2700 (for example by moving sourcesSetFor out), then a coordinator check and the gate; or a fix by hand.

    Written by an agent.

  13. added
    bug:blocked
    and removed
    bug:ready
    on Nov 15, 2026
  14. removed their assignment
    on Nov 15, 2026
  15. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1546 — gate refused twice: src/drivers/ios/index.ts over its listed 2700 lines after the Fallow fix (#1563)
    Decided: #1546 — three untested late-copy behaviours → kept as built and pinned by tests

    Written by an agent.

  16. added
    bug:ready
    and removed
    bug:blocked
    on Nov 15, 2026
  17. self-assigned this
    on Nov 15, 2026
  18. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1563 (#1546)
    Decided: #1546 — three untested late-copy behaviours → kept as built and pinned by tests

    Written by an agent.

  19. added a commit that references this issue on Nov 17, 2026
    6dcbd34
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