You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Orphan iOS devices stay on disk after a failed shutdown; cleanup doesn't see them #1801
On a 16 GB Mac under memory pressure, deleting a simulator at lease end runs simctl shutdown with a 30 s timeout. The daemon log shows it timing out, then the device is quarantined and the reclaim retries fail:
device.purge-failed DriverCrashError: simctl shutdown <udid> timed out after 30000ms
device.quarantined kind: shutdown-failed
quarantine reclaim retry failed (attempts 3)
Some of those simulators stay in ~/.simlock/devices/ios with no row in simlock list. I had three (1.2 to 1.5 GB each), left on 0.7.0. After upgrading to 0.8.0 and restarting the daemon they were still there, and only doctor saw them:
$ simlock --version
0.8.0
$ simlock list # only the one live lease
$ simlock cleanup --dry-run
[]
$ simlock doctor
{"findings":[{"kind":"orphan-device", ... "platform":"ios"}, (x3) ...]}
A handful of these push the disk under the 10 GB pressure line. Two orphans in an earlier batch came from provisions whose requests were then rejected with unresolvable-spec, so a rejected request may also leave its new simulator behind.
This looks like the shutdown/delete side of #1546. #1563 bounded clone/create and deletes a late copy, but the shutdown at lease end still has the fixed 30 s limit, and a daemon restart does not reconcile the orphans.
What I expected
A quarantined device whose retries are used up gets a last forced simctl delete.
cleanup (or a periodic doctor reconcile) removes orphan-device findings.
A rejected request deletes the simulator it created.
How to reproduce
The shutdown timeout only happened under memory pressure (swap about 2.5 GB, pressure "warn"), so that part is intermittent. Once orphans exist, the list / cleanup / doctor check above shows them every time.
Environment
simlock 0.8.0 (orphans created on 0.7.0), macOS 27, iOS 27.2 runtime.
Workaround
simlock doctor --purge-orphans --yes removed all three on 0.8.0 without a daemon restart. A restart alone does not clear them.
Suggested fix
Give the shutdown at lease end the same kind of setting #1563 added for clone/create, and run the orphan reconcile from cleanup or on a timer.
This is a decision, not a defect. ADR 0001 §6 rejects reaping orphans automatically. The three orphans match #1546 (a clone cut off at 30 s on 0.7.0), which #1563 fixed in 0.8.0 for new clones. The test's expectation is the reporter's proposal.
src/core/doctor-unobservable-platform.test.ts, "a daemon start's reconcile destroys every orphan device in the owned root without --purge-orphans". Branch bug/1801-repro.
pnpm exec vitest run --project unit src/core/doctor-unobservable-platform.test.ts
AssertionError: expected [] to deeply equal [ …(2) ] (no device.orphan-purged for orphan-1, orphan-2)
❯ src/core/doctor-unobservable-platform.test.ts:126:7
Root cause
src/core/doctor.ts:216-226 purges orphans only under --purge-orphans. cleanup rules (src/core/cleanup/rules.ts:5) read only registry records, so they never see a device with no record. Both follow ADR 0001 §6 and safety rule 1: an orphan has no record and no claim, so an automatic reaper could delete a device that is between driver.provision and registerDevice for a live request. Two tests pin this (doctor.test.ts:478, doctor-unobservable-platform.test.ts:65). A lease-end shutdown failure does not create orphans. The device stays registered and quarantined, and a retry deletes it (quarantine-coordinator.ts:306-327). A rejected unresolvable-spec is the second ProvisionFailedError (acquisition-workflow.ts:549-553): on 0.7.0 that was the timed-out clone.
Simplest fix
None inside the rules. Making reconcile or cleanup purge needs an ADR that supersedes ADR 0001 §6 and answers its mid-provision race, so it needs a spec session. If the decision stands, close this as covered by #1546/#1563, with doctor --purge-orphans --yes as the cleanup for 0.7.0 leftovers.
Alternatives rejected
Purge in doctor --fix: ADR 0001 §6 keeps it a separate flag so unattended --fix runs never start destroying.
Purge at daemon start: the same race with a provision that is running.
Activity
V3RON commentedon Nov 22, 2026
Reproduction
This is a decision, not a defect. ADR 0001 §6 rejects reaping orphans automatically. The three orphans match #1546 (a clone cut off at 30 s on 0.7.0), which #1563 fixed in 0.8.0 for new clones. The test's expectation is the reporter's proposal.
src/core/doctor-unobservable-platform.test.ts, "a daemon start's reconcile destroys every orphan device in the owned root without --purge-orphans". Branchbug/1801-repro.Root cause
src/core/doctor.ts:216-226purges orphans only under--purge-orphans.cleanuprules (src/core/cleanup/rules.ts:5) read only registry records, so they never see a device with no record. Both follow ADR 0001 §6 and safety rule 1: an orphan has no record and no claim, so an automatic reaper could delete a device that is betweendriver.provisionandregisterDevicefor a live request. Two tests pin this (doctor.test.ts:478,doctor-unobservable-platform.test.ts:65). A lease-end shutdown failure does not create orphans. The device stays registered andquarantined, and a retry deletes it (quarantine-coordinator.ts:306-327). A rejectedunresolvable-specis the secondProvisionFailedError(acquisition-workflow.ts:549-553): on 0.7.0 that was the timed-out clone.Simplest fix
None inside the rules. Making reconcile or
cleanuppurge needs an ADR that supersedes ADR 0001 §6 and answers its mid-provision race, so it needs a spec session. If the decision stands, close this as covered by #1546/#1563, withdoctor --purge-orphans --yesas the cleanup for 0.7.0 leftovers.Alternatives rejected
doctor --fix: ADR 0001 §6 keeps it a separate flag so unattended--fixruns never start destroying.Risk
--purge-orphans.Fast track
Side findings
Written by an agent.