Skip to content

fix(ssh): keep managed remote server ownership through stop - #215

Open
leoisadev1 wants to merge 2 commits into
mainfrom
fix/ssh-runner-ownership
Open

fix(ssh): keep managed remote server ownership through stop#215
leoisadev1 wants to merge 2 commits into
mainfrom
fix/ssh-runner-ownership

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

SSH-managed servers started through npx/npm can outlive Disconnect or app shutdown. The launcher recorded the npm wrapper PID, so stop signaled npm while the server kept its listener and database open. A failed installer that printed a path could still launch, and a stop that timed out still deleted ownership files.

Fix

  • Exec the CLI path already resolved by the install preflight, so the recorded PID is the server.
  • Check the installer's exit status before accepting stdout. Keep npm's stderr and report installation failure without guessing a C-compiler cause.
  • Confirm the saved process has exited before removing PID, port, and ownership files. If it stays alive after the two-second wait, keep those files and return SshCommandError.
  • Run connect and disconnect in order for each target so reconnect cannot overtake an earlier stop.

External servers remain running. No remote force-kill was added.

Adaptation

Reviewed port of pingdotgg/t3code#9843, #10088, and #10105. Package and executable names stay akeru-bot / akeru. Hosted relay was not added.

Scope

This PR is SSH runner, install diagnostics, and stop ownership only. Cookie isolation is #208. LAN vs Tailscale pairing and Zed remote open are separate PRs.

Verification

  • vp test run packages/ssh: 54 passed, including POSIX runner PID ownership, installer ETARGET/network/empty-success/success paths, stop timeout keeping ownership files, disconnect failure retry, and per-target reconnect ordering.
  • vp run --filter @t3tools/ssh typecheck exited 0.
  • Targeted lint on the changed files reported no errors.

No live bot/group UI changed. Native remote SSH hosts were not used; tests run a real POSIX runner against fixture package managers and a local Node listener.

Implemented with Grok 4.6 High in Grok Build via Orca.

SSH-managed servers started through npx/npm can outlive Disconnect because the
launcher recorded the wrapper PID. Exec the resolved CLI, treat installer
non-zero exits as failures, and keep ownership files when the remote process
is still alive. Connect and disconnect on one target run in order.

Adapted from pingdotgg#9843, pingdotgg#10088, and pingdotgg#10105.

Implemented with Grok 4.6 High in Grok Build via Orca.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
akeru-bot-landing Building Building Preview Sep 10, 2026 5:42pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This change improves SSH-managed Akeru server lifecycle handling by ensuring reconnect and disconnect work is ordered consistently, preserving remote process ownership, and surfacing shutdown failures.

Confidence Score: 5/5

Safe to merge.

The reconnect/disconnect race is fully addressed: both operations acquire the same target lock before resolving the target, preventing a reconnect from returning a tunnel while an earlier disconnect is stopping it. The first prior thread was resolved by greptile-apps[bot] without explanation. leoisadev1 dismissed the retained-lock concern, accepting the risk because one semaphore per target for the desktop session is intentional and deleting it could allow a reconnect while shutdown is still running.

Files Needing Attention: None.

Reviews (2): Last reviewed commit: "fix(ssh): serialize target resolution wi..." | Re-trigger Greptile

Comment thread packages/ssh/src/tunnel.ts
Comment thread packages/ssh/src/tunnel.ts
Acquire the per-target lock before SSH host resolution so a slow disconnect
cannot lose the race to a later reconnect.

Implemented with Grok 4.6 High in Grok Build via Orca.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant