Skip to content
docs/architecture
Get started

When things restart or fail

Laptops suspend, controllers restart, networks drop. Throughout, the controller’s record of what should be running is the durable thing, and what is actually running gets reconciled against it.

The state you see — working, needs input, idle, done, errored — and underneath it a flag saying whether it is meant to be running. An agent that exits clears the flag, and so does an explicit kill, so nothing resurrects a session you ended. A controller restart does not clear it, which is why those sessions come back.

Sessions it was running locally went with it. On the next start it restarts each one still flagged as wanted, and the agent picks its conversation up where it left off. Shells reopen in the same working directories. Published forwards and directory shares come back at the same URL, so a link you already handed out keeps working. A resume that fails marks that session failed with the reason instead of leaving a row that claims to be running.

Sessions on other machines were never the controller’s processes. They kept running while it was away.

The link is pinged every 15 seconds and gives up after 50 with nothing inbound, because a suspended laptop leaves a socket that reports no error at all.

Its sessions stay visible and you can still open them. Input pauses, and each pane says which worker is offline instead of failing silently. Keystrokes are never buffered through an outage — typing into a paused pane does not queue bytes that land minutes later.

The reason distinguishes the two setups, because they are different problems: a worker that dials out has not connected, while a worker the controller dials cannot be reached at its endpoint.

It announces every terminal it still has, and the controller re-adopts the ones it expected, resumes the ones that are missing, and kills anything it did not expect or that belongs to a session since stopped.

Output the worker buffered while it was away is collected rather than lost: it keeps each finished terminal’s output on disk and hands it over on reconnect, so a crash on either side leaves a recoverable copy.

Its sessions show as awaiting worker. Nothing about them is changed — not the state, not the timestamps — because the controller still intends to resume them. Session and board links open; anything needing the worker fails with the offline reason.

If the worker stays gone past the grace period, its sessions are failed with worker did not reconnect, except those still owned by automatic recovery.

  • File descriptors run out first. A worker holds three per terminal and two per forwarded connection, so a few dozen sessions has little room under the 1024 soft limit most distributions ship. pm daemon and pm worker each raise their own soft limit to 65536 at startup and log what they changed. A machine whose hard limit is low needs that raised outside pm.
  • A slow viewer is dropped rather than allowed to hold a terminal’s output back for everyone else. It reattaches and gets a fresh replay.
  • A shell created while a worker is disconnecting is rolled back, so no terminal appears later belonging to nothing.