Skip to content

iOS runCommand passes timeoutMs to spawn, which ignores it, and its comment relies on that backstop #1980

Done

Description

@V3RON

src/drivers/ios/command-run.ts:24-26 computes runnerTimeoutMs and passes it to processRunner.spawn, with the comment "the runner's own timeout is a backstop past the late kill". NodeProcessRunner.spawn reads no timeoutMs, so there is no backstop. runCommand itself still answers at its own clock timer, but a command that ignores the one SIGTERM it sends is never escalated to SIGKILL.

ProcessRunOptions (src/ports/process-runner-types.ts:2) accepts timeoutMs for spawn although the ports manual says spawn takes none, so the compiler flags neither this call nor the one in #1979.

Read in the code on origin/main at dead1fb, not run. Found while triaging #1979.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 30, 2026
  2. self-assigned this
    on Nov 30, 2026
  3. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Seen on: fakes (scripted runner, fake clock). A scratch run with the real NodeProcessRunner and a Node child ignoring SIGTERM agreed. Not seen from a real simctl.

    src/drivers/ios/index-seed-sources.test.ts on bug/1980-repro: "a simctl command that ignores the SIGTERM sent when its time is up is sent SIGKILL 10 s later, and one that ends at the SIGTERM is not".

    $ pnpm exec vitest run --project unit src/drivers/ios/index-seed-sources.test.ts
    AssertionError: expected { list: [ { …(2) } ], …(3) } to deeply equal …   :190:21
    clone:  - { atMs: 340000, signal: "SIGKILL" }   (missing; diff abridged)
    list:   - { atMs: 40000,  signal: "SIGKILL" }
    Tests  1 failed | 39 passed (40)
    

    Root cause

    Defect, as filed, and worse than filed for a clone. src/drivers/ios/command-run.ts:38 sends one SIGTERM; the backstop named at line 24 does not exist, because spawn arms no timer (src/ports/node-process-runner.ts:106). A late clone that ignores SIGTERM never settles waited, so onSettled never runs (line 52) and SeedTurns.hold (src/drivers/ios/simctl.ts:112) never lifts: deleting that seed waits forever and nothing is logged. The iOS manual promises "5 silent minutes more kills and logs it". Scratch measurements:

    real child, 13 s after its limit:   today alive       fixed gone
    seed deletion, 24 h after a clone:  today pending     fixed done at 340 s, 1 warning
    

    Simplest fix

    In runCommand, after the SIGTERM set a 10 s clock timer that sends SIGKILL, cancelled when waited settles. Correct the comment. Keep the argument for now (side finding).

    fix tried, then restored
    vitest unit, src/drivers/ios + driver-contract + src/ports: 1222 passed | 58 skipped
    pnpm test:changed: 1808 passed | 47 skipped; pnpm typecheck: clean
    timer not cancelled: the reproduction fails
    

    Alternatives rejected

    • NodeProcessRunner.spawn honours timeoutMs: contradicts the ports manual.
    • Only drop the argument and comment: the hang stays, and 41 tests fail.
    • Switch to run: its timer bypasses the injected clock, and late needs the handle.

    Risk

    • Today a clone that ignores SIGTERM and answers after 340 s has its copy deleted; killed, it leaves the copy, with a warning. simctl imports signal handlers (nm -u); which signals is unmeasured.
    • The grace applies to every runCommand caller: simctl, devicectl, open, defaults, pgrep.
    • 10 s copies installer-process.ts and NodeProcessRunner; the test pins it.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: no — a clone answering after 340 s despite SIGTERM is cleaned up today and would not be
    • No ADR or rule changed: yes
    • One fix: no — sparing the late clone from SIGKILL would change what is left on disk

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 30, 2026
  5. added
    bug:ready
    and removed
    bug:new
    on Dec 1, 2026
  6. self-assigned this
    on Dec 2, 2026
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