Skip to content

Stream commands (git stacked action, server update) are interrupted when the RPC WebSocket closes, and the client does not resubscribe #125

Closed

Description

@immakermatty

What happens

A stream command keeps running on the server only while the browser's RPC WebSocket stays open. gitRunStackedAction (commit, push and create the pull request) is one, and serverUpdateServerWithProgress is another. If the socket closes mid-command, for example when the gateway ends it or the network drops, the server stops the command. The client does not resubscribe, so the person sees an error and has to start the command again.

  • Server: apps/server/src/ws.ts runs gitRunStackedAction inside Stream.callback, around line 2820 at c81c1e0. The git workflow runs in the stream's fiber.
  • Effect RPC: when a client disconnects, RpcServer interrupts every fiber of that client (disconnect → fiber.interruptUnsafe, and an Interrupt for each open request). So the git workflow is interrupted, and with it any child process (git push) it is waiting on.
  • Client: packages/client-runtime/src/rpc/client.ts lists gitRunStackedAction, serverUpdateServerWithProgress, cloudInstallRelayClient and chatGptHandoffSubscribe as stream commands. Unlike subscriptions, stream commands are not resubscribed after a reconnect.

Everything else in T3 Code already survives a reconnect:

  • subscriptions move to the new session;
  • threads catch up from their last event (afterSequence);
  • terminals re-attach with resume: true and a snapshot;
  • agent runs live on the server.

Why it matters now

Lazurio's Environment gateways will soon close every upgraded connection five minutes after it opens. A removed member's open connection then ends without waiting for the browser (decided 2026-10-24; tracked in the Machines repository).

With that bound, any stream command still running when its connection ends is cut. Expected rates:

  • a 5-second git action: about 1 in 60;
  • a 1-minute server update: about 1 in 5.

Until T3 Code handles this, the bound waits.

Expected behaviour

A stream command started by a person finishes on the server even if the socket that started it closes. After the client reconnects, it either reattaches to the command's progress or gets its result.

For example, the server could run the command outside the request's fiber, keyed by the existing actionId. The client could then:

  • re-subscribe by actionId, or
  • read the command's result from the state it already resyncs (git status, the thread's pull request link).

A command that fails on its own still reports its error.

Tests

  • A regression test closes the socket during gitRunStackedAction. The commit, push and pull request still complete, and after the reconnect the client shows the result.
  • The same test covers serverUpdateServerWithProgress, or that command documents why a cut is harmless for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions