Skip to content

fix(ssh): re-arm remote watches that die without a reconnect - #10456

Merged
brennanb2025 merged 5 commits into
brennan/sta-2525-remote-file-changes-are-not-detected-over-ssh-until-the-filefrom
brennanb2025/sta2525-followup-watch-death-no-reconnect
Jul 25, 2026
Merged

brennanb2025 merged 5 commits into
brennan/sta-2525-remote-file-changes-are-not-detected-over-ssh-until-the-filefrom
brennanb2025/sta2525-followup-watch-death-no-reconnect

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Stacked on #10445 — review that first; the base branch here is brennan/sta-2525-remote-file-changes-are-not-detected-over-ssh-until-the-file.

#10445 re-arms remote file watches when the SSH provider re-registers, which covers a reconnect and a first connect slower than the 60s give-up. Provider registration is the only re-arm trigger it adds, and that leaves two holes this PR closes. Both were confirmed by a failing test before either fix was written.

Gap 1 — a watch that dies without a reconnect (77c2b9a306)

Remote OOM, inotify/fd exhaustion, or the relay watcher being killed all leave the SSH link perfectly healthy, so no registration ever follows. The watch went handleRemoteWatcherTerminalError → 1s retries → capped at REMOTE_WATCH_RETRY_TIMEOUT_MS (60s) → one give-up overflow → dead until the app restarts. That overflow refreshes the tab once and then the tab silently stops updating — the original STA-2525 symptom.

After the fast window gives up, the key now arms a bounded backoff off the existing desiredRemoteWatchers intent: 60s doubling to a 30-minute ceiling. A permanently broken remote costs roughly 5 fs.watch calls in the first half hour instead of 60 in the first minute.

It stands down rather than competing when something else owns recovery: a live remoteWatchers entry, an in-flight fast retry, an empty listener set, a deliberate removal, or no SSH provider at all — the last one hands the reconnect case back to #10445's registration hook instead of adding wire traffic to a link already being rebuilt. The timer is unref()'d so a half-hour timer never holds the process alive at quit.

Gap 2 — the file-explorer watch never recovered either (fd55ed997f)

SshFilesystemProvider.dispose() calls stopSshFilesystemWatchRegistration, which — unlike failSshFilesystemWatchRegistration — never invokes terminalCallbacks. So a transport drop fires no terminal callback for the file-explorer lease.

The renderer does not rescue it: useFileExplorerWatch / useEditorExternalWatch only take the runtime path when runtimeEnvironmentId is set, failSharedRuntimeFileWatch merely deletes the shared watch, and both onError handlers only console.warn. The file tree therefore stayed stale across a reconnect even with #10445.

Fixed entirely in the main process by reinstalling on the connection's next provider registration and emitting overflow. No renderer change was needed.

Testing

8 new tests across two sibling files (filesystem-watcher-dormant-rearm.test.ts, orca-runtime-files-ssh-rearm.test.ts — sibling files because filesystem-watcher.test.ts is at the 800-line lint cap and max-lines disables are forbidden). Every one proven non-vacuous by mutating the source and watching it fail.

Gates: 132/132 across the touched test files, tsc --noEmit clean, oxlint clean.

Not verified

No real SSH host — Gap 1 in particular is verified by code trace and mocked-provider tests, not by inducing a real remote inotify exhaustion. No Windows/WSL run.

Note

CI verify is currently red repo-wide, not from this PR: .github/workflows/release-cut.yml reintroduced generate-skill-bundle-manifest into its bump step in #10340, which package-electron-runtime-contract.test.mjs explicitly forbids. It fails identically on pristine main.

The 60s fast-retry window gave up with a single overflow and no further
trigger — provider registration is the only re-arm, and a watch killed by
remote OOM/inotify exhaustion leaves the SSH link perfectly healthy. Back
off from 1min to a 30min ceiling instead, and stand down entirely when the
provider is gone so registration owns that case.
SshFilesystemProvider.dispose() stops each watch registration without
invoking its terminal callbacks, so a dropped transport left the runtime
file-explorer watch silently dead: the lease's restart only runs from the
failed-removal path, and the renderer's runtime subscription stays open
because it rides a different link. Reinstall on the connection's next
provider registration and emit overflow so clients resync.
@brennanb2025
brennanb2025 merged commit 3951672 into brennan/sta-2525-remote-file-changes-are-not-detected-over-ssh-until-the-file Jul 25, 2026
1 check 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