Repository navigation
fix(ssh): time out stalled remote file streams - #11364
Conversation
📝 WalkthroughWalkthroughAdded a 60-second inactivity deadline for SSH file streams. The deadline pauses during system suspend and re-arms on resume. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryAdds a 30-second inactivity deadline to SSH file stream reads so that a stalled stream (one that sends metadata but then stops delivering chunks) is automatically cancelled and rejected instead of blocking the session scanner indefinitely.
Confidence Score: 5/5Safe to merge. The change is tightly scoped to SSH file stream reading, uses only Node built-in timers with no new dependencies, and every terminal path consistently clears the timer and removes listeners. The deadline module is small and single-purpose. Integration in the stream reader is correct: streamIdRef is populated before the timer starts, so fs.cancelStream always carries a valid stream ID. Both fail() and succeed() call inactivity.clear() before any further side-effects, ruling out double-fire. Two focused fake-timer tests verify the stall path and the long-but-active path, including listener and timer count assertions confirming no leaks. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/ssh/ssh-file-stream-inactivity-deadline.ts | New file: clean re-settable deadline wrapper; correctly unref's the timer and nulls it out inside clear() before re-arming in reset(). |
| src/main/ssh/ssh-filesystem-stream-reader.ts | Integrates the inactivity deadline correctly: started after streamIdRef is populated, reset per chunk, and cleared on every terminal path. |
| src/main/providers/ssh-filesystem-provider-stream.test.ts | Two new fake-timer tests verify stall cancellation/listener cleanup and long-but-active-transfer liveness; afterEach guard prevents timer state leakage. |
Reviews (1): Last reviewed commit: "fix(ssh): time out stalled remote file s..." | Re-trigger Greptile
7bb56f5 to
cc710d1
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 382b1508-c8f7-4636-902b-596ef1c923d8
📒 Files selected for processing (10)
config/reliability-gates.jsoncsrc/main/index.tssrc/main/providers/ssh-filesystem-provider-stream.test.tssrc/main/ssh/ssh-file-stream-inactivity-deadline.tssrc/main/ssh/ssh-filesystem-stream-reader.tssrc/main/startup/desktop-startup-ordering.test.tssrc/main/system-power-lifecycle.test.tssrc/main/system-power-lifecycle.tssrc/main/system-resume-broadcast.test.tssrc/main/system-resume-broadcast.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/ssh/ssh-filesystem-stream-reader.ts
| type SystemPowerLifecycleListener | ||
| } from '../system-power-lifecycle' | ||
|
|
||
| export const SSH_FILE_STREAM_INACTIVITY_TIMEOUT_MS = 60_000 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Locate relevant files =="
git ls-files | rg '(^src/main/ssh/ssh-file-stream-inactivity-deadline\.ts$|^config/reliability-gates\.jsonc$|ssh-file-stream-inactiv|reliability-gates)' || true
echo
echo "== Git diff stat/name =="
git diff --stat || true
echo
echo "== Current constants =="
sed -n '1,40p' src/main/ssh/ssh-file-stream-inactivity-deadline.ts 2>/dev/null || true
echo
echo "== Reliability gate relevant excerpts =="
rg -n '"invariant"|"30 seconds"|"30-second"|"knownGaps"|"30 uninterrupted|post-metadata|reliability-gates|inactivity|SSH_FILE_STREAM_INACTIVITY_TIMEOUT_MS' config/reliability-gates.jsonc src/main/ssh/ssh-file-stream-inactivity-deadline.ts 2>/dev/null || true
echo
echo "== All repository occurrences of timeout and related strings =="
rg -n 'SSH_FILE_STREAM_INACTIVITY_TIMEOUT_MS|ssh-file-stream-inactiv|30 seconds|30-second|30 uninterrupted awake seconds|post-metadata inactivity deadline|inactivity deadline' . -g '!node_modules' -g '!dist' -g '!build' || trueRepository: stablyai/orca
Length of output: 50369
Align the SSH file-stream inactivity timeout with the reliability-gate target. SSH_FILE_STREAM_INACTIVITY_TIMEOUT_MS is 60_000, but the gate text requires cancellation within 30 seconds in three places. Pick the intended timeout and update the code or the gate entries together.
📍 Affects 2 files
src/main/ssh/ssh-file-stream-inactivity-deadline.ts#L6-L6(this comment)config/reliability-gates.jsonc#L205-L206config/reliability-gates.jsonc#L278-L279
* fix(ssh): time out stalled remote file streams * test(ssh): cover stream dispose-listener cleanup * fix(ssh): pause file stream deadlines during sleep * fix(ssh): replay suspended state to late streams * fix(ssh): allow slower file stream progress --------- Co-authored-by: OrcaWin <[email protected]> Co-authored-by: Jinwoo-H <[email protected]>
Summary
Fixes #11362.
This PR is intentionally scoped to the SSH file-stream lifecycle. It does not change AI Vault session discovery, provider filters, file-size limits, or parsing behavior.
Screenshots
Observed symptom on stable cask releases
The screenshot uses the Korean UI; 세션 스캔 중 means Scanning sessions. It was captured after installing the latest stable Homebrew cask available at approximately 2026-07-29 15:00 KST (
v1.4.160). After updating to the current stable cask (v1.4.161), the same indefinite loading symptom reproduced again.The screenshot documents the user-visible loading state, but no per-stream trace was captured during those runs, so it does not by itself establish that a stalled stream caused a specific instance. The focused regression tests isolate the verified stream-layer defect: after metadata arrives, a stream that produces neither another chunk nor a terminal frame previously had no deadline.
When that condition occurs, this PR cancels and rejects the read after 30 seconds of inactivity, allowing the session scanner to settle through its existing result/error path instead of waiting forever.
Testing
pnpm lintpnpm typecheckpnpm buildpnpm test— PR branch: 3,777 passing files / 39,949 passing tests with 8 failures; cleanupstream/main: 3,777 passing files / 39,947 passing tests with the same 8 failures in the two Codex runtime-home rollback suitespnpm vitest run src/main/providers/ssh-filesystem-provider-stream.test.ts(10/10)pnpm run check:code-quality:changed -- upstream/mainAI Review Report
Security Audit
fs.cancelStreamcapability and existing cleanup pathNotes