Skip to content

Investigate implicit shutdown after an external emulator restart #4585

Open

Description

@thymikee

Purpose

Follow up on PR #4539, r4572557061. Plain close should not stop a new emulator boot that another actor started after the session’s original boot. This is separate from the Android cold-open acceptance runs still required by #4162.

Current evidence

At 0e19c8dfaf2a549bd6cfd49d3b1c50d56ee83dcd, the source permits this sequence:

  1. A session opens a stopped local Android emulator and records bootedByOpen: true.
  2. Another actor stops and starts the emulator, retaining its serial and the daemon’s claim file.
  3. The session reopens its app. Claim renewal verifies token/process identity and stamps updatedAtMs; it does not observe the device’s current boot. Android session refresh returns the stored device. updateOpenDevice retains boot ownership for the same device identity.
  4. Plain close can renew that claim and request shutdown of the current emulator boot.

See reopen, renewal, stored Android device, retained boot ownership, and implicit shutdown.

This is a source trace, not a runtime reproduction. No live external-reboot case has run. The earlier Darwin iOS stale-snapshot rejection does not settle this scenario. The existing boot-observation service already distinguishes device boots for claim acquisition; claim currency and ownership of a particular boot answer different questions.

Required behavior and completion

  • First reproduce the sequence through the routed open/close lifecycle with real claim handling. Record whether the second open actually boots anything and whether close asks for shutdown.
  • If reproduced, tie implicit-stop authority to the boot this session caused at the owning lifecycle/claim boundary. Reuse existing boot observation where appropriate. Specify behavior when boot observation is unavailable before implementation.
  • Preserve actual cold-reopen ownership, same-boot reopens, explicit close --shutdown, policy-denied warnings, provider/physical exclusions, and claim takeover behavior. A blanket selection.source === 'local' condition would drop legitimate cold reopens.
  • Add a regression that fails on the observed wrong shutdown and passes after the fix. Verify both a same-boot reopen and an external restart. Cover close without an intervening reopen if the reproduction exposes the same gap.
  • Run the affected exact-head checks and supported live-device verification before claiming the device behavior fixed.

No speculative guard, new flag, release workaround, or change to #4162’s pending acceptance evidence is included in this follow-up.

Activity

  1. apex-sentinel-staging commented on Nov 16, 2026

    @apex-sentinel-staging

    Apex Sentinel · Issue review

    Suggested label: bug

    The issue identifies a concrete existing behavior that is wrong: after an external emulator restart, a session's plain close can still request shutdown of the current boot, and it points to source locations plus required reproduction and tests.

    Required sections

    • Steps to reproduce (missing)
    • Expected and actual behavior (missing)
    • Version or environment (missing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions