You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
android: check ownership before the readiness code stops an emulator whose boot failed #4867
#4863 stops the emulator a cold boot launched when the boot fails for a non-deadline reason, from the Android readiness code (packages/platform-android/src/readiness/runtime.ts). That stop is gated by the device-shutdown policy, but it has no check that another session or device claim holds the emulator. A second open that binds to the booting emulator-NNNN could lose it when the first open's boot fails afterwards.
The daemon's failed-open cleanup (stopUnownedLaunch, #4842) already does this check: session holding the device, claim held by another owner, both under the per-device claim lock, plus the pid and start-time identity.
Required behavior
Before the readiness stop signals the launched pid, no other session or claim holds that device. Decide where the check lives: make the readiness stop ownership-aware, or route a failed boot through the daemon's existing cleanup path so there is one stop path with all gates.
Completion conditions
A test where another session or claim holds the booting emulator and the first open's boot fails: no stop is attempted.
The issue describes a concrete race/defect in Android readiness code stopping an emulator without verifying no other session or claim owns it. It provides a required behavior and completion conditions, so a maintainer can act on it.
Optional follow-ups from the final review of #4863 (#4863 (comment)), to take with this issue because they touch the same code:
Derive the keep in packages/platform-android/src/readiness/runtime.ts from !bootWaitDone && clock.now() >= deadlineAtMs and drop the bootBudgetSpent marker from error.details.
Reword the ADR 0029 amendment: the emulator host gates its own terminate, and the daemon's launched-process stop uses the deviceShutdownDenied flag.
Add one composition test through createPlatformRuntimeHost with a throwing assertShutdownAllowed that expects deviceReadiness.androidEmulator.terminate to reject (src/platform-runtime-operation-host.ts).
Note for whoever takes this: an implementation of the second option (route a failed boot through the daemon's existing failed-open cleanup, so one stop path has the policy gate, the session check, the claim lock and the pid identity) was written during #4863 and set aside when the review chose the smaller policy-gate fix. It is the local commit 1c81fba458 ("keep the failed-open stop in one place"), kept on the unpushed local branch redesign-4863-not-pushed. It was not reviewed and not validated against the merged #4863. The design choice between the two options in this issue is still open for the maintainer.
Activity
apex-sentinel-staging commentedon Nov 20, 2026
Apex Sentinel · Issue review
Suggested label:
bugThe issue describes a concrete race/defect in Android readiness code stopping an emulator without verifying no other session or claim owns it. It provides a required behavior and completion conditions, so a maintainer can act on it.
Required sections
thymikee commentedon Nov 21, 2026
Optional follow-ups from the final review of #4863 (#4863 (comment)), to take with this issue because they touch the same code:
packages/platform-android/src/readiness/runtime.tsfrom!bootWaitDone && clock.now() >= deadlineAtMsand drop thebootBudgetSpentmarker fromerror.details.terminate, and the daemon's launched-process stop uses thedeviceShutdownDeniedflag.createPlatformRuntimeHostwith a throwingassertShutdownAllowedthat expectsdeviceReadiness.androidEmulator.terminateto reject (src/platform-runtime-operation-host.ts).thymikee commentedon Nov 21, 2026
Note for whoever takes this: an implementation of the second option (route a failed boot through the daemon's existing failed-open cleanup, so one stop path has the policy gate, the session check, the claim lock and the pid identity) was written during #4863 and set aside when the review chose the smaller policy-gate fix. It is the local commit
1c81fba458("keep the failed-open stop in one place"), kept on the unpushed local branchredesign-4863-not-pushed. It was not reviewed and not validated against the merged #4863. The design choice between the two options in this issue is still open for the maintainer.