Skip to content

fix(ssh): a reconnected transport starts managed orcad itself instead of inheriting a dropped start - #25689

Merged
OrcaWin merged 4 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-idle-relaunch-race
Oct 6, 2026
Merged

OrcaWin merged 4 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-idle-relaunch-race

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​43 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20

ELI5

When Orca restarts a server it manages on an SSH host, and the SSH connection drops partway through, the next connection could report the server as running even though it wasn't. Every action on that host then failed. Now the new connection starts the server itself instead of reusing the failed attempt's answer.

What Changed

Before: the client starts a stopped managed server whenever it connects (#25121). To avoid starting it twice when two callers ask at the same moment, it shared one in-progress start per server. Here is the failure case:

  1. A start is running on one SSH connection.
  2. That connection drops. One example: the app reconnects a host on launch, and then the user, or the e2e test, reconnects it again.
  3. The caller on the new connection joins the start that was still running on the dead connection.
  4. That start fails because its connection is gone. The new caller is handed the same failure: "the server couldn't be started".
  5. The connect still reports the host as managed, but no server is running.

This is the flake in ssh-orcad-idle-exit.spec.ts:50: the connect returned kind: 'managed', and the host had no orcad process.

After: a caller only shares an in-progress start that runs on the same SSH connection, connect generation and port. That is the same rule the short-lived "server is up" cache already followed. A caller on a reconnected transport runs its own check. It probes the server, proves the old process is gone, takes over the fence its own interrupted start left behind (#25470 added that), and launches the server. The wake's in-memory record of its own fence is now cleared only by the wake that wrote it, so a late failure on the dead connection can't erase the newer wake's record.

Why

  • It's a real race, not test timing. Any SSH drop during a start leaves the reconnected client reporting a host that is managed but has no server. The e2e test just hits it reliably, because it reconnects right after the app's own launch-time reconnect.
  • Why share by transport and not drop sharing. Two callers on the same live connection, such as a fresh tunnel and the connect right after it, still share one check, so there is no double probe and no double launch. A second launch is also prevented on the host by the activation fence and by orcad's instance lock.
  • The fence the dropped start held. The first CI run showed the real cause. The start on the dropped connection still held the host's activation fence, and the reconnected start couldn't prove that fence was its own, so it gave up as "fenced". There are two changes:
    • A start now records its owner token in memory before writing it to the host.
    • A start on a new connection first waits for this client's start on the dropped connection to finish. After that, the token that start left is known.
      A fence is released only if its owner file carries this process's own token. A fence with no owner file is never claimed, because it could be another client's fresh fence that hasn't written its owner file yet. A test covers that case.

Linked Issue

Fixes # (Phase 3 follow-up; e2e flake on #25602 and #25405)

Visual Proof

N/A. No UI change.

Testing

  • New unit test in orcad-managed-serving.test.ts. A start is in progress on one connection. The connection's generation changes, which models a reconnect, and a new caller arrives. The old start then fails with "SSH connection lost". The new caller must run its own start and get started. Without the fix, it inherits unverifiable and the test fails; I ran it against the reverted code to confirm.

  • The e2e spec now also asserts that the relaunch connect carries no serving note, so if this regresses the failure names the cause.

  • Local: the orcad and SSH host-server unit suites pass (14 files, 169 tests). Typecheck and the changed-code quality gate pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The SSH case is the subject of this change. The fix is not platform specific, so Windows hosts follow the same path. No wire changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — this is the first pullfrog review, covering the full PR.

  • Shared an in-flight or recent serving check only on the same SSH transport (connection identity + connect generation + remote port), so a reconnected transport runs its own check instead of inheriting the dropped start's failure as unverifiable.
  • Made a wake on a reconnected transport settle the prior same-host wake first, and claim its owner token before the on-host write, so a fence its own dropped wake left can be proven and released.
  • Restricted releaseOwnInterruptedWakeFence to a fence whose owner file is present and matches this process's token; a fence with no owner file is never claimed.
  • Added unit coverage that a reconnected caller runs its own start, and that a fence with no owner token is refused.
  • Extended the idle-exit e2e to assert the relaunch connect carries no serving note.

The wake path was traced end to end: the runningWakes await is a linear, bounded chain (no cycle), settle()'s token-equality guard prevents one wake from clearing another's token, and the require owner present + match change is equivalent to the pre-PR base behavior when the owner write is lost (base claimed the token after the write, so it could not release either). Both changed unit suites pass (21 tests).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

m4air added 4 commits October 5, 2026 17:27
… inheriting a dropped one

The serving check deduplicated in-flight starts by environment only. When a
connect dropped mid-start (as when the launch-time auto-connect is replaced
by a reconnect), the caller on the new transport joined the start bound to
the dead one, got its failure, and reported the host managed with no server
running. In-flight checks now join only on the same connection, connect
generation and port, and a wake's own fence token is cleared only by that
wake.
… at any point

The flake's real verdict was 'fenced': the dropped launch-time wake held the
activation fence, and the reconnected wake could not prove it its own. A
wake now claims its token before its first remote step, an absent owner
record under a held token is still its own, and a reconnected wake waits for
this client's dropped wake to settle before reading the fence.
A fence with no owner file could be another client's fresh one. Releasing it
now requires the owner token this process wrote; the token is claimed before
the write so a drop after it still proves ownership.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p3-idle-relaunch-race branch from c1b0d65 to 7ff2191 Compare October 6, 2026 00:33
@OrcaWin
OrcaWin merged commit 5d689d0 into OrcaWin/node-rt-phase3 Oct 6, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant