Skip to content

fix(android): cancel the shutdown wait's timer so a stopped daemon exits - #250

Merged
V3RON merged 3 commits into
mainfrom
bug/237
Oct 2, 2026
Merged

V3RON merged 3 commits into
mainfrom
bug/237

Conversation

@V3RON

@V3RON V3RON commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Closes #237

After daemon stop, the daemon process stayed alive for up to 180 s. The Android driver's #waitForExit armed a second timer inside the Promise.race timeout branch and never cancelled it, so when the emulator exited first that timer kept the event loop alive until readinessTimeoutMs ran out.

#waitForExit now arms one timer, keeps its handle, and cancels it in a finally after the race. This covers both the normal exit and a wait() that rejects. timerFired is gone. On timeout it still returns false, so the SIGKILL path still runs.

Other places that race against a clock timer in src/drivers/android/ and src/drivers/ios/ were checked. The iOS xcrun runner already cancels its timer in a finally. The two #delay helpers are plain awaited sleeps, not races. Neither needed a change.

Checklist

  • Regression test: "leaves no timer armed once each shutdown has seen its emulator exit" in src/drivers/android/index.test.ts. This is the triage test, and it now passes.
  • The timeout path still sends SIGKILL: covered by the new test "kills an emulator that has not exited within the readiness timeout of a shutdown". It fails if the timeout branch resolves true.
  • A rejected wait leaves no timer armed: covered by the new test "leaves no timer armed when waiting for the emulator to exit fails". It fails without the finally.
  • pnpm check passes.

Review

Spec review: 0 findings. Code review: 2 findings, 2 fixed (second round: 0 findings).

Written by an agent.

V3RON added 3 commits October 2, 2026 17:51
The timeout branch of #waitForExit armed a second timer that was never
cancelled, so a stopped daemon stayed alive until it fired (up to
readinessTimeoutMs, 180 s by default). Keep one timer and cancel it after
the race.
@V3RON
V3RON merged commit 4e311b5 into main Oct 2, 2026
14 checks passed
@V3RON
V3RON deleted the bug/237 branch November 6, 2026 07:09
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.

The daemon process stays alive for about two minutes after daemon stop

1 participant