Skip to content

fix(clean): bump simctl probe timeout and retry on cold boot#896

Merged
tw93 merged 4 commits into
tw93:mainfrom
xronocode:fix/890-simctl-cold-boot-timeout
May 15, 2026
Merged

fix(clean): bump simctl probe timeout and retry on cold boot#896
tw93 merged 4 commits into
tw93:mainfrom
xronocode:fix/890-simctl-cold-boot-timeout

Conversation

@xronocode
Copy link
Copy Markdown
Contributor

Summary

  • Bump simctl probe timeout from 2s to 5s.
  • Add single retry at 8s with debug-log marker when CoreSimulatorService warmup exceeds initial timeout.

Problem

On cold boot, CoreSimulatorService can take >2s to initialize. The probe:

run_with_timeout 2 xcrun simctl list devices > /dev/null 2>&1

fails, and mo clean reports simctl not available even though simctl works fine once the service is warm. The first failed probe actually warms the service, so the next run succeeds.

Fix

  • Increase initial timeout to 5s (covers most warmup scenarios).
  • If that fails, retry once at 8s with a debug log noting the warmup retry.
  • Total worst case: ~13s (vs hanging indefinitely without timeout).

Testing

  • bats tests/dev_extended.bats --filter "simctl" → 1/1 ok

Fixes #890

CoreSimulatorService can take >2s to warm up on cold boot, causing
a false "simctl not available" report. Bump initial timeout from 2s
to 5s and add a single retry at 8s with a debug-log marker.

Fixes tw93#890
@xronocode xronocode requested a review from tw93 as a code owner May 14, 2026 07:35
xronocode added 3 commits May 14, 2026 13:48
- Sleep 1s before retry to give CoreSimulatorService more wall time
- Unify log message to match comment (CoreSimulatorService)

tw93#890
The existing simctl test (`clean_dev_mobile continues cleanup when
simctl is unavailable`) mocks `xcrun` as a shell function, which puts
the probe into the `declare -F xcrun` branch — NOT the timeout-retry
branch where the tw93#890 fix lives. The fix was therefore untested.

This test exercises the actual fix path:

  - Installs a real `xcrun` shim on PATH so `command -v xcrun` succeeds
    AND `declare -F xcrun` returns false, forcing the else branch.
  - Stubs `run_with_timeout` to return 124 (timeout) on the first probe
    and 0 on the retry, mirroring CoreSimulatorService warmup on cold
    boot.
  - Asserts the retry-success debug line appears in output and the
    "simctl not available" fallback message does NOT.

Verified red-green: with the timeout/retry change reverted, the test
fails on the `succeeded on retry` assertion; with the fix in place it
passes.
Add a debug_log entry on the failure branch of the retry so a future
operator inspecting the debug session can tell that two probe attempts
were made (5s + 8s) before falling through to the "simctl not
available" notice. Without this, the user-visible message gives no
diagnostic hint that we already retried.
@tw93 tw93 merged commit 35d856f into tw93:main May 15, 2026
8 of 9 checks passed
xronocode added a commit to xronocode/pages that referenced this pull request May 15, 2026
- tw93/Mole#895 — fix(clean): apply should_protect_path in dry-run for orphaned system services
- tw93/Mole#896 — fix(clean): bump simctl probe timeout and retry on cold boot

Both merged by @tw93 2026-05-14; Mole card now has 5 merged PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mo clean reports simctl not available on cold boot

2 participants