Skip to content

simlock adb disconnect drops every leased emulator on Simlock's adb server #1168

Closed

Description

@V3RON

The virtual passthrough refuses kill-server because "it would detach every leased emulator at once", but passes disconnect with no address through to Simlock's shared server. adb answers that by kicking every emulator transport, since emulators are local transports:

src/drivers/android/index.ts:418   "disconnect" is on NO_DEVICE_SUBCOMMANDS, so no -s is added
src/drivers/android/index.ts:829   only kill-server, three emu sequences and scope flags are refused
adb (packages/modules/adb main) adb.cpp: host:disconnect: with an empty address -> kick_all_tcp_devices()
adb transport.cpp kick_all_tcp_devices: kicks every t->IsTcpDevice(), and IsTcpDevice() is type == kTransportLocal, which emulator transports are

So one holder's simlock adb disconnect drops every other lease's emulator for about a second, and their adb reverse/forward rules go with it. The physical handler already refuses disconnect (physical-handler.ts:36).

Found while triaging #1162.

Written by an agent.

Activity

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

    @V3RON
    ContributorAuthor

    Reproduction

    Defect, confirmed. One more case than the issue lists: disconnect <serial> kicks the emulator it names, and nothing checks that serial. Branch bug/1168-repro, src/drivers/android/index.test.ts: "refuses adb disconnect with or without an address, on the local CLI and through device.exec". The test tries disconnect, -s emulator-5554 disconnect and disconnect emulator-5556, each from the local CLI and from device.exec.

    pnpm exec vitest run --project unit src/drivers/android/index.test.ts -t "refuses adb disconnect"
    AssertionError: promise resolved "{ args: [ '-P', '5038', 'disconnect' ], … }" instead of rejecting
    

    What adb does with it (adb main source, read, not run):

    adb.cpp:1443               empty address -> kick_all_tcp_devices()
    adb.cpp:1450               otherwise find_transport(address) -> kick_transport(t)
    transport.h:341            IsTcpDevice() is type == kTransportLocal
    transport.cpp:1505         every socket transport is kTransportLocal
    transport_emulator.cpp:159 emulator reconnect callback: ReconnectResult::Abort
    

    Correction to the issue: the drop may last longer than "about a second". A kicked emulator does not reconnect. With ADB_EMU=0, only Simlock announces it again (index.ts:2011, during a readiness wait, or at daemon start). Not measured on hardware.

    Root cause

    src/drivers/android/index.ts:830. #assertProxyable refuses only kill-server (REFUSED_ADB_VERB, :306), the three emu sequences and scope flags. disconnect is on NO_DEVICE_SUBCOMMANDS (:418), so no -s is added and nothing refuses it. Simlock's shared server runs it and detaches other leases' emulators. physical-handler.ts:36 already refuses it.

    Simplest fix

    Refuse disconnect when it is the subcommand (found through walkGlobals, as isBareShell does), with a message that starts Refusing `simlock adb disconnect` . Add a row to the refusal table in working-with-a-device.mdx and to cli.mdx:189.

    Alternatives rejected

    • Refuse only the bare form: disconnect emulator-5556 still kicks another lease's emulator.
    • args.includes("disconnect"): it would also refuse shell echo disconnect.
    • Add disconnect <own serial>: reconnecting needs a re-announce, so the lease would lose its own emulator.

    Risk

    • Refuse it only in subcommand position. Do not refuse it when it is an operand.
    • Update NO_DEVICE_SUBCOMMANDS and ADR 0047 §1, which lists disconnect, if the fix removes it there.

    Written by an agent.

  4. removed their assignment
    on Nov 1, 2026
  5. V3RON commented on Nov 1, 2026

    @V3RON
    ContributorAuthor

    Agreed fix

    The maintainer agreed to the triage report's simplest fix: refuse disconnect as the adb subcommand (with or without an address) on the local CLI and through device.exec, so shell echo disconnect still works, and update the refusal tables in working-with-a-device.mdx and cli.mdx. The failing test on bug/1168-repro (6738389) is the starting point.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 1, 2026
  7. self-assigned this
    on Nov 1, 2026
  8. V3RON commented on Nov 1, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1180 (#1168)

    Written by an agent.

  9. added a commit that references this issue on Nov 1, 2026
    d6cbd85
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