Skip to content

simlock adb through a gateway hangs while a piped stdin stays open #1172

Closed

Description

@V3RON

simlock adb and simlock simctl against a gateway (the remote path) never run their command when stdin is a pipe that stays open. They wait for stdin to close first, so a caller that spawns the CLI with a piped stdin it never closes hangs forever. Coding agents and scripts often start child processes that way.

  • src/cli/commands/passthrough.ts:57: runRemotePassthrough awaits environment.readStdin() before it calls client.exec.
  • src/cli/environment.ts:409: readStdin defaults to readPipedStdin, which reads to end of file whenever stdin is not a TTY.

Seen while making the tunnel slow-lane tests pass (#1110, PR #1127). A test's simlock adb --lease <id> shell … through a gateway never returned until the test closed the child's stdin. The output showed nothing, so it looked like the tunnel failing.

Expected: a command that doesn't need input runs without waiting for stdin to close, or the CLI documents that it reads piped stdin to EOF and gives a way to say there is no input.

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

    Decision, not a defect. The CLI does what ADR 0005 §19c says: "a piped stdin is read to EOF first and sent as 19a's one-shot string." The test's expectation is a proposal for a superseding ADR. Branch bug/1172-repro, src/cli/index.test.ts, "runs $tool through a gateway without waiting for a piped stdin that stays open" (adb and simctl). It fakes readStdin as a promise that never settles, so no timer decides the result.

    pnpm exec vitest run --project unit src/cli/index.test.ts -t "piped stdin that stays open"
    
    FAIL  runs adb through a gateway without waiting for a piped stdin that stays open
    AssertionError: expected [] to deeply equal [ { args: [ 'shell', 'getprop' ], …(3) } ]
    FAIL  runs simctl through a gateway without waiting for a piped stdin that stays open
    AssertionError: expected [] to deeply equal [ { args: [ 'list' ], …(3) } ]
    

    It passes when the gateway path skips the stdin read (checked locally, not pushed).

    Root cause

    src/cli/commands/passthrough.ts:58 awaits environment.readStdin() before client.exec. The default, readPipedStdin (src/cli/stdio.ts:5), reads any non-TTY stdin until EOF. A pipe nobody closes never gets EOF, so device.exec is never sent. ADR 0005 §19a's one-shot stdin string means the CLI must have all of stdin before it sends. The hang is the known cost of that choice: e2e/gateway-smoke.test.ts:180 says so and works around it with input: "".

    Simplest fix

    A superseding ADR for §19c, then opt-in stdin through a gateway: a --stdin flag, removed from the arguments next to --lease in extractLeaseFlag (passthrough.ts:81). Without it, the CLI never reads stdin, like docker exec -i and kubectl exec -i. The flag name is my proposal. Update website/.../reference/cli.mdx:172 ("a piped stdin is sent along"); the existing one-shot-stdin test then needs the flag.

    Alternatives rejected

    • Stream stdin over device.exec: changes the wire on HTTP, the uplink and MCP, so it is a feature.
    • Only document </dev/null: callers that spawn with stdio: "pipe" still hang silently.
    • Send what arrived within a short wait: timing-dependent, races with slow writers.

    Risk

    • Breaking: echo x | simlock adb shell cat through a gateway would need --stdin.
    • The workaround comment in gateway-smoke.test.ts becomes out of date.
    • The local (worker) path keeps inherited stdio, unchanged.

    Written by an agent.

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

    @V3RON
    ContributorAuthor

    Being specified in #1174. This issue stays open until that feature ships.

    Written by an agent.

  6. github-actions commented on Nov 1, 2026

    @github-actions
    Contributor

    Shipped as #1174.

  7. V3RON commented on Nov 1, 2026

    @V3RON
    ContributorAuthor

    Fixed by #1174, which merged as #1178. Through a gateway, simlock adb and simlock simctl no longer read stdin unless you pass --stdin, so a pipe that stays open can't hang them. To send input, use simlock adb --stdin shell cat < file.

    Written by an agent.

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

    bug:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions