Skip to content

fix(ports): run() always ends its child at a deadline, and Android boot probes get what is left of the boot deadline - #1584

Merged
V3RON merged 3 commits into
callstackincubator:mainfrom
miospotdevteam:fix/process-deadlines
Nov 20, 2026
Merged

V3RON merged 3 commits into
callstackincubator:mainfrom
miospotdevteam:fix/process-deadlines

Conversation

@miospotdevteam

@miospotdevteam miospotdevteam commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ProcessRunner.run() armed its kill timer only when the caller passed timeoutMs, and several Android calls passed none. The worst is the readiness wait: its three probes had no deadline, so an adb that hangs on one holds the lease request and its running slot until the daemon restarts.

Change

  • run requires a deadline. ProcessRunner.run takes BoundedRunOptions, whose timeoutMs is required (architecture rule 11). There is no default. spawn is unchanged.
  • Each Android call names its own bound: adb devices in the port allocator 30 s (ADB_DEVICES_TIMEOUT_MS), the mark write 5 s, emulator -version 30 s, avdmanager create and delete 60 s (AVDMANAGER_TIMEOUT_MS).
  • Boot probes. #bootProbe gives each probe what is left of android.bootTimeoutMs and throws BootTimeoutError when it runs out.

Tests

  • process-runner.test.ts: run ends a child at its timeoutMs, and at once for 0 and Infinity.
  • index-boot.test.ts: three rows, one per probe that never exits, each failing with BootTimeoutError at android.bootTimeoutMs.

Assumptions

  • Assumption: a probe's bound — the whole remaining boot deadline, not a shorter limit with a retry.
  • Assumption: the allocator's adb devices bound — the 30 s listManaged already gives the same command.

Review

Spec review: skipped. Code review: 0 blocking, 0 fixed, 1 notes. Claims review: skipped.
Rounds: 2. Tokens: 1.5M.
Runs: 2. Cost USD: 0.5363. Agent seconds: 139.

  • code: android.bootTimeoutMs has no upper bound (src/drivers/android/definition.ts:54), so a value above 2^31 ms would fire the probe timer at once; unrealistic, not blocking.

Assessment: complete

Written by an agent.

…ot probes get what is left of the boot deadline

run() armed its kill timer only when the caller passed timeoutMs, so a
call without one waited for its child for ever. It now applies a 60 s
default on the same SIGTERM-then-SIGKILL path. The three Android
readiness probes get the time left of android.bootTimeoutMs, so a hung
adb ends the boot with BootTimeoutError instead of holding the lease
request and its reserved slot. avdmanager create avd names its own
deadline. A dependency-cruiser rule keeps child_process imports in
src/ports/ to the runner and the long-lived launchers.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ProcessRunner.run now requires a timeout, and NodeProcessRunner terminates timed-out processes with SIGTERM before scheduling SIGKILL. Android SDK helper runs use a 60-second default, while Android driver commands supply operation-specific timeouts. Emulator boot probes now share the configured boot deadline. Tests and runner adapters pass required timeout options and cover process and boot-probe timeout behavior.

Suggested reviewers: v3ron

Merge Risk: Minimal · up to 0e694

This change gives every process run a deadline and bounds Android boot probes by the remaining boot deadline. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: ProcessRunner.run() always ends its child at a deadline, and Android boot probes receive the remaining boot deadline. The changeset matches both parts. The title …
Description check Passed The description states the problem, the change, the tests, and the assumptions. It matches the changeset: run() requires timeoutMs through BoundedRunOptions, Android calls receive explicit timeouts, b…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: ProcessRunner.run() always ends its child at a deadline, and Android boot probes receive the remaining boot deadline. The changeset matches both parts. The title is long (116 characters), but it is specific and on-topic.

Full details: Description check

Explanation

The description states the problem, the change, the tests, and the assumptions. It matches the changeset: run() requires timeoutMs through BoundedRunOptions, Android calls receive explicit timeouts, boot probes use the remaining boot deadline, and tests cover the timeout behavior.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: d6115da5-fbd3-4efa-bddc-9c7dfad9dd3b
Commits

Reviewing files that changed from the base of the PR and between 3372d0d and 0e6943a.

Files selected for processing: 1

  • src/drivers/android/index-boot.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@V3RON

V3RON commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. The bug is real: on Android, an adb probe that hangs during boot keeps the lease request and its running slot held until the daemon restarts. Here is a review in three parts.

Better solution

What the PR solves: run() with no timeoutMs waits for ever. Several Android calls pass none, and the boot deadline is only checked between probes, so it cannot end a probe that hangs.

The boot probe half is the right fix. #bootProbe gives each probe the time left on one deadline measured from startedAt, and maps a runner timeout to BootTimeoutError. That is what architecture rule 11 asks for ("the budget does not reset"), and the iOS boot already works this way (#1575, one deadline across boot, bootstatus and listapps). Keep it.

The 60 s default in run() is the part I would change. Rule 11 asks for an explicit deadline on every wait that crosses a process boundary. On today's main, every non-Android run() and runOrThrow() call already names its own timeoutMs: iOS, launchd/schtasks in service-manager.ts, the updater, npm, the admission command, setup and fseventsd. The only calls without one are the Android calls this PR lists. A simpler fix that fits better:

  • Make timeoutMs required for run (for example, a ProcessRunOptions for run with timeoutMs: number, kept apart from the spawn options). The compiler then lists the six remaining calls.
  • Give each of them a bound that fits it, instead of one shared 60 s. adb devices runs inside the console-port allocator's lock and blocks every other Android boot, so it should get a short bound (about 10 s), not 60 s plus the 10 s SIGKILL grace. The mark write and emulator -version are also short. avdmanager delete can keep 60 s.
  • Drop defaultRunTimeoutMs and its constructor option.

Why this is better: a future caller that forgets a deadline gets a compile error, not a child that is killed silently after 60 s with code: null on some slow host. ScriptedProcessRunner ignores timeoutMs, so no unit test would ever show a default that is too short. A required field also makes the child-process-owners rule unneeded for this goal. That rule does not enforce deadlines anyway (spawn sets none), so I would leave it out or move it to its own PR.

Side effects

  • The branch conflicts with main and the lint rule would break after a rebase. Since the PR's base (6db7d04, 76 commits behind), main split src/ports/process-runner.ts into node-process-runner.ts, process-runner-types.ts and process-tree-kill.ts. On main, the files under src/ports/ that import child_process are byte-pipe.ts, daemon-launcher.ts, node-process-runner.ts, process-tree-kill.ts and updater-launcher.ts. The allowlist names process-runner.ts, which no longer imports it, and leaves out node-process-runner.ts and process-tree-kill.ts. As written, pnpm lint would fail. The runner hunks also have to move to node-process-runner.ts.
  • The default reaches every platform, now and later. I scanned every non-test run() and runOrThrow() on main. Today no non-Android call changes behaviour, because each one already names a deadline. Any future call without one (a long xcodebuild, sdkmanager or simctl step) would be cut at 60 s with no warning. The proposal above removes this risk.
  • Comment claim. The DEFAULT_RUN_TIMEOUT_MS comment says 60 s is "the longest deadline a caller in this tree gives a command that is not an install, a copy or a boot". iOS READBACK_TIMEOUT_MS is 120 s (src/drivers/ios/index.ts:208). The comment goes away if the default goes. If it stays, the comment needs rewording.
  • Lock hold time. With the default, a hung adb devices holds the allocator lock for up to about 70 s (60 s plus the 10 s SIGKILL grace) and blocks every Android boot for that time. That is better than for ever, but long. See the short bound above.
  • The boot can end a little after android.bootTimeoutMs. An adb that ignores SIGTERM is killed 10 s later, and then the emulator is stopped. The PR states this. It is fine.
  • No change to init.svc.bootanim errors. The probe failure still throws DriverCrashError with the same message runOrThrow produced.
  • Not affected: config keys, the wire protocol, defaults that users see, existing leases, seeds and baselines (AVD_CREATE_TIMEOUT_MS sits inside the seed-make ceiling), and the website docs. android.bootTimeoutMs now does what its docs already say.

Review

The blind pre-merge review (review skill) at a63a491:

PR: #1584  Round: 1  Kind: fix  Commit: a63a491a671cd196b45de7cc6bcedcee74748262
Assessment: complete
Risk: high (changes subprocess lifetime and the Android boot deadline). Lenses: code/both and claims, run as an author self-check; spec skipped (no issue). The PR's tests were not run.
Spec review: skipped  Code review: 0 findings (0 blocking)  Claims review: 0 findings (0 blocking)
Fix: none
Ledger: no findings. Every non-test run/runOrThrow call site was scanned: the ones without a timeout are short commands, so the 60 s default is safe for them; long operations use spawn or an explicit timeoutMs. #bootProbe passes each probe the time left on the boot deadline and maps a runner timeout to BootTimeoutError. The child-process-owners rule matches the only child_process importers under src/ports/ at the PR's base.
Notes: claims: the DEFAULT_RUN_TIMEOUT_MS comment says 60 s is the longest deadline given to a non-install/copy/boot command; iOS READBACK_TIMEOUT_MS is 120 s (src/drivers/ios/index.ts:208). Nonblocking.
Why: no blocking defects found at the PR's own base.

The review checked the PR on its own base. The conflict with main and the outdated allowlist (see Side effects) come from main moving on since then. Neither is a defect in the diff itself, but both must be fixed before this can merge.

Written by an agent.

… default

main split process-runner.ts into node-process-runner.ts, process-runner-types.ts
and process-tree-kill.ts, and moved the boot-deadline test to index-boot.test.ts;
the PR's changes are carried to those files.

As proposed in the review: ProcessRunner.run takes BoundedRunOptions, whose
timeoutMs is required (architecture rule 11 asks for an explicit deadline), so
the compiler finds a call without one. The default and its constructor option
are gone. The Android calls that had none now name their own bound:
adb devices in the port allocator uses ADB_DEVICES_TIMEOUT_MS (30 s), the mark
write 5 s, emulator -version 30 s, avdmanager create and delete
AVDMANAGER_TIMEOUT_MS (60 s). The child-process-owners lint rule is dropped:
the type now holds the rule. #bootProbe is kept as it was.
@V3RON
V3RON merged commit 5b688e1 into callstackincubator:main Nov 20, 2026
42 of 44 checks passed
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.

2 participants