Skip to content

iOS baseline save fails: ENOENT on device.plist.sb-* temp file #1714

Closed

Description

@degill

What happens

On Simlock 0.8.0 (macOS 26.7.1, Xcode 27.2, iOS 27.2 runtime), every
simlock baseline save of an iOS lease fails, also for a freshly leased bare
simulator:

{"error":{"code":"BASELINE_SAVE_FAILED","message":"baseline zz-probe was not saved: ENOENT: no such file or directory, lstat '~/.simlock/devices/ios/sources/<udid>/device.plist.sb-55c05b11-ISuHtw'. Lease lse_… has ended."}}

Reproduced 3 of 3 times. The device used for the save can end up
quarantined with the same error in shutdown failed.

Steps

  1. simlock lease --platform ios --device "iPhone 17 Pro" --os 27.2 --ttl 30m (kept running in the background)
  2. Wait for boot.
  3. simlock baseline save zz-probe --lease <id>

Cause

saveSource in dist/drivers/ios/seeds.js runs simctl clone into the
sources set and right afterwards #baselineRecord → recordLineageFiles.
visitFolder in dist/drivers/ios/lineage-files.js readdirs the clone's
folder and then lstats each entry. CoreSimulator is still writing the
clone's device.plist atomically, so its temp file device.plist.sb-*
is listed but gone by the time of the lstat, and the ENOENT aborts the
save.

Fix that works locally

Skip entries that vanish between readdir and lstat:

const details = await options.filesystem.lstat(path).catch((error) => {
    if (isMissingPathError(error))
        return undefined;
    throw error;
});
if (details === undefined)
    continue;

With this patch the save succeeds, the baseline leases, and the app state
(login, app group defaults) survives.

Activity

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

    @V3RON
    Contributor

    Reproduction

    Confirmed. src/drivers/ios/index-seed-record.test.ts, "a baseline is saved when files listed in its clone are gone before the walk reaches them, and only the files still there are recorded", on bug/1714-repro. The fixture lists two *.sb-* temp files (top level and nested) that are removed when lstat reaches them.

    pnpm exec vitest run --project unit src/drivers/ios/index-seed-record.test.ts
    
    AssertionError: expected Error: ENOENT: no such file or directory,… to be undefined
    + "message": "ENOENT: no such file or directory, open '/Devices/sources/EEEEEEEE-…/data/Library/Preferences/app.plist.sb-0a1b2c3d-QwErTy'"
     ❯ src/drivers/ios/index-seed-record.test.ts:338:25   expect(saved.error).toBeUndefined();
    

    Root cause

    Defect. src/drivers/ios/lineage-files.ts:97: visitFolder readdirs the clone's folder, then lstats each name with no handling for a name that is gone. CoreSimulator still writes the clone's plists atomically after simctl clone returns, so its *.sb-* temp file is listed and renamed away before the lstat; the ENOENT escapes recordLineageFiles, and saveSource (seeds.ts:175) deletes the clone and fails. The seed make walks the same code, so it can fail the same way.

    Simplest fix

    The reporter's patch at lineage-files.ts:97: an lstat that fails with isMissingPathError skips the entry; any other error still throws.

    git diff --stat   # 1 file, +6 -1 in lineage-files.ts
    pnpm exec vitest run --project unit src/drivers/ios/index-seed-{record,sources,provision,swap,throwaway}.test.ts src/drivers/ios/index-save-source-lifecycle.test.ts
    Test Files  6 passed (6)   Tests  74 passed (74)
    

    Alternatives rejected

    • Wait or retry after simctl clone until the folder settles: no signal says when CoreSimulator is done, so it is a guessed delay.
    • Skip names matching *.sb-*: ties the walk to an Apple naming detail; any vanished file breaks it the same way.

    Risk

    • A file gone between lstat and classify is recorded unreadable with a warning, not skipped. Harmless for a copy's swap (counted only); not covered by the test.
    • The WAL loop at lineage-files.ts:91 still throws on a vanished -wal; untouched by the fix.

    Fast track

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

    Written by an agent.

  4. removed their assignment
    on Nov 19, 2026
  5. added
    bug:readyAn agent may fix it.
    and removed
    bug:newReported. An agent may triage it (rule 8); the fast track may set it ready (rule 17).
    on Nov 19, 2026
  6. self-assigned this
    on Nov 19, 2026
  7. V3RON commented on Nov 19, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1786 (#1714)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

  8. maxlapides commented on Nov 19, 2026

    @maxlapides

    @V3RON Thanks for merging #1786. I found one follow-up case: if a device.plist.sb-* file survives the lineage scan and contains a source UDID, Simlock can record its path. If CoreSimulator removes the file afterward, a later baseline lease can fail when it tries to rewrite that path.

    I ran the regression from #1785 against the code that merged in #1786. The baseline save succeeded, but the lineage still contained device.plist.sb-in-progress. With #1785, the test records only the canonical device.plist. The follow-up filters those temporary files at the clone root and keeps #1786’s handling of vanished entries throughout the clone.

  9. added a commit that references this issue on Nov 20, 2026
    f8cf4b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyAn agent may fix it.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions