Repository navigation
fix(ssh): stop a markerless native-deps probe from deleting both native modules - #18011
Conversation
The repair path read "the probe answered, but nothing in the answer names a dep" as "both deps are missing". The POSIX probe is fenced with `|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe catch added by #17979 never ran. A node that cannot start (invalid NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher and burned a 240s npm install that failed the same way. `.install-complete` from the original install survives, so the relay kept launching with no PTY and no file watcher, permanently, per host. Only a marker line that actually names deps is evidence about them; anything else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the POSIX probe and carry stderr into the warning via a new execCommand `onStderr` hook, so the reason node failed survives. stderr stays its own stream — folded into stdout it would match the probe's own token strings. The Windows branch shared the same parser and is fixed with it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughSSH command execution now reports successful stderr through an optional callback while resolving stdout. Native-dependency probes now capture stderr and classify responses without named dependencies as unverifiable. Dependency repair uses only explicitly named missing dependencies. Tests and shared fixtures now cover Linux and Windows probe responses, selective repair, and both-dependency markers. Merge Risk: ⚪ Minimal · up to The change prevents ambiguous native-dependency probes from deleting both modules while preserving targeted repairs when a dependency is explicitly identified. No actionable merge-blocking risk remains; the PR is merge-ready after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description clearly explains the failure mode, fix, rationale, linked issues, regression trade-off, and test results. It provides sufficient information for review, although several optional template headings and checklist items are omitted.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
missingNativeDepsFromProbereturnsundefinedfor a markerless answer — a node that can never start (badNODE_OPTIONS, OOM kill, exit 127) no longer manufactures "both deps missing" and triggersrm -rfofnode-ptyand@parcel/watcherplus a node-gyp source build on every reconnect of an affected host.probeRequiredNativeDepsmaps that tounverifiableand emits an[NATIVE-DEPS-PROBE-UNPARSEABLE]warning carrying the stdout/stderr tails;2>/dev/nullwas dropped so the one line that identifies the host-side failure survives.execCommandgains an optionalonStderrinvoked only on the zero-exit resolve path, marker-token-redacted, and destructured out ofexecOptionsso it never leaks intoconn.exec.probeInstalledNativeDepsreports?? []for a markerless answer —availablealready carries the failure, and the first-install rebuild path keys offavailablerather thanmissing.- Tests — new verdict tests pin the no-repair path (POSIX and Windows markerless) and the stderr-through-
onStderrwiring; fixtures gained a sharedBOTH_NATIVE_DEPS_MISSING_PROBEso bare'MISSING'no longer doubles as "both broken". I ranpnpm test src/main/ssh/ssh-relay-native-deps-probe-verdict.test.ts src/main/ssh/ssh-relay-deploy-helpers.test.ts→ 36 passed.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…stablyai#18011) The repair path read "the probe answered, but nothing in the answer names a dep" as "both deps are missing". The POSIX probe is fenced with `|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe catch added by stablyai#17979 never ran. A node that cannot start (invalid NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher and burned a 240s npm install that failed the same way. `.install-complete` from the original install survives, so the relay kept launching with no PTY and no file watcher, permanently, per host. Only a marker line that actually names deps is evidence about them; anything else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the POSIX probe and carry stderr into the warning via a new execCommand `onStderr` hook, so the reason node failed survives. stderr stays its own stream — folded into stdout it would match the probe's own token strings. The Windows branch shared the same parser and is fixed with it. Mirror-Of: 4f4872c
…stablyai#18011) The repair path read "the probe answered, but nothing in the answer names a dep" as "both deps are missing". The POSIX probe is fenced with `|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe catch added by stablyai#17979 never ran. A node that cannot start (invalid NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher and burned a 240s npm install that failed the same way. `.install-complete` from the original install survives, so the relay kept launching with no PTY and no file watcher, permanently, per host. Only a marker line that actually names deps is evidence about them; anything else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the POSIX probe and carry stderr into the warning via a new execCommand `onStderr` hook, so the reason node failed survives. stderr stays its own stream — folded into stdout it would match the probe's own token strings. The Windows branch shared the same parser and is fixed with it.

Closes the destructive half of #18007. Follow-up to #17979 (merged), which fixed the unanswered probe and left the answered-but-unparseable one asserting the maximally destructive conclusion. I fenced that fix away from this on reasoning that was wrong.
ELI5
missingNativeDepsFromProbereturned "both deps missing" whenever the probe output had no marker line. But the POSIX probe was(node -e '<js>' 2>/dev/null || echo MISSING), and that subshell always exits 0 — so #17979'scatch → unverifiablebranch never fired. Ifnodeitself failed to start, stdout was the bare stringMISSING, no marker, and the result wasrm -rf node_modules/node-ptyandrm -rf node_modules/@parcel/watcherplus a node-gyp compile.2>/dev/nullhad already discarded the one diagnostic that would have distinguished the cases.This was deterministic and permanent per host. An invalid
NODE_OPTIONSin~/.profile, an OOM-killednode -e, or exit 127: every connect deletes both deps,npm installfails the same way,finalizeInstallis skipped — but.install-completefrom the original install is still present, soisRelayAlreadyInstalledkeeps returning true. The relay launches with no node-pty and no file watcher, and because repair runs on every connect for an installed dir, each reconnect re-deletes and burns another four minutes. It never self-heals. Strictly worse than the transient bug #17979 fixed.The fix
missingNativeDepsFromProbereturnsRelayNativeDepName[] | undefined—undefinedfor a markerless answer and for a marker naming zero recognized deps. It no longer manufactures a dep list from no evidence.probeRequiredNativeDepsmaps that tounverifiable(fix(ssh): stop an unanswered native-deps probe from wiping a healthy relay #17979's existing verdict — no fourth added) and warns[ssh-relay][NATIVE-DEPS-PROBE-UNPARSEABLE]with the tail of stdout and stderr. Only a marker naming ≥1 dep yieldsblocked.2>/dev/null. New optionalonStderronexecCommand, invoked on the zero-exit resolve path where stderr was previously discarded, withredactRelayInstallMarkerTokensapplied.Deliberately not
2>&1: the probe JS source contains the literal stringsORCA-NATIVE-DEPS-OKandORCA-NATIVE-DEPS-MISSING:, and node echoes-esource into stderr on an uncaught throw — folding the streams could manufacture a falseokand permanently suppress a real repair.Windows had the same hole and is fixed by the same change: a native non-zero exit does not throw in PowerShell, so
try { & node -e … } catch { 'MISSING' }yields empty, markerless stdout. It sharesmissingNativeDepsFromProbe. There is now an end-to-end control for it.User-facing regressions
One, deliberate and stated. A native module whose load aborts the process (uncatchable dlopen crash, cf. #9902) leaves no marker, so it is now
unverifiableand launches degraded instead of triggering a blind reset.That trade is correct: the blind reset was indistinguishable from the
NODE_OPTIONS/OOM/exit-127 case and did far more damage there, and a crash on dlopen is not reliably fixed by reinstalling the same version on the same host. If it needs covering later, the honest fix is a synchronousfs.writeSync(2, …)breadcrumb in the probe naming the dep it is about to require — turning the crash into an answer with a marker, rather than widening what counts as evidence.Otherwise none. A genuinely broken dep still repairs: the probe JS catches
requirefailures per-dep and printsORCA-NATIVE-DEPS-MISSING:<names>, so one named dep resets one, both named resets both.Testing
Failing before the source fix, passing after (test file unchanged between runs):
After:
Tests 8 passed (8).Negative controls pass before and after, so they pin the repair path rather than moving with it: a marker naming
@parcel/watcherresets exactly that dep and not node-pty; a marker naming both resets both and callsfinalizeInstallonce; anORCA-NATIVE-DEPS-OKanswer runs nonpm install; #17979's unanswered probe still launches intact. Plus anexecCommandunit test that a zero-exit command's stderr reachesonStderrand does not leak intoconn.execoptions.pnpm test src/main/ssh: 1803 passed, 16 skipped.tc:nodeclean.check:code-quality:changed0 new findings across 7 files.Fixture note
Bare
'MISSING'in repair-path fixtures now means unverifiable, so suites using it to mean "both deps broken" were feeding the wrong evidence. The string changed, never the slot count — no positional array shifted. 7 slots inssh-relay-sftp-namespace-install.test.tsand 3 inssh-relay-native-deps-install.test.tsnow shareBOTH_NATIVE_DEPS_MISSING_PROBE, which also replaces two inline copies.