Repository navigation
fix(ssh): repair unbuilt relay native deps - #8686
Conversation
📝 WalkthroughWalkthroughNative dependency deployment now uses direct module loading for health checks, enables npm lifecycle scripts during installation, and makes the node-pty helper executable on POSIX hosts. Failed probes trigger 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d67507fa-521a-4cb2-bee0-6018f40febc3
📥 Commits
Reviewing files that changed from the base of the PR and between f01bfd9 and 7798009807d3b40edfda55c2c65097c4da8239ad.
📒 Files selected for processing (2)
src/main/ssh/ssh-relay-deploy.tssrc/main/ssh/ssh-relay-native-deps-install.test.ts
|
thx for the PR. Reviewing it now |
|
Took this over and pushed a hardening commit (
An earlier iteration added an on-disk "unrepairable" marker to skip repeat repairs, but adversarial review showed it could persist a transient rebuild failure as permanent — so it was dropped for the simpler always-retry + non-fatal design. The recurring-repair cost on a genuinely-unbuildable already-installed host is documented in the PR description as a bounded, non-fatal tradeoff (with a session/TTL-memo follow-up noted). Full |
1ee62e3 to
04371c3
Compare
|
Internal review complete — no known code blockers on final pushed head The final hardening covers real native-module loading probes, forced npm lifecycle scripts for repair, nonfatal degraded launch, same-process native reload from the deployed bundle, single-flight node-pty loading, and bounded install/rebuild/re-probe behavior. The locking and GC paths were also hardened against the adversarial cases found during review: PowerShell 5.1-compatible directory locks remain visible to older clients, stale recovery uses tokenized atomic claims and unique tombstones, safety probes fail closed, locked state is rechecked after fencing, launch fencing closes the repair-to-liveness deletion window, contention retries until the deploy deadline, and failed launches retain recoverable fences. Validation on the exact final candidate:
Required PR Checks passed on the final SHA, including full lint, typecheck, the repository-wide test suite, unpacked app build, and packaged CLI smoke. No merge was performed. |
|
Caution Review failedAn error occurred during the review process. Please try again later. 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 |
Hardening on top of the ignore-scripts native-deps repair so it can never leave a user worse off than before the change: - repairInstalledNativeDeps is now best-effort. An already-installed relay can always launch in degraded mode (fs/git/preflight still work), so a repair failure must not block the connection. Neither lock contention nor an offline/unbuildable repair aborts the deploy now: on lock-acquire failure we degrade without releasing a lock we do not hold; on repair-body failure we release our lock and fall through to a degraded launch. Pre-repair the health check used require.resolve (which passed for a present-but-unloadable binding), so a fatal repair here was a straight regression for offline / no-toolchain hosts. The fresh-install path keeps its fatal semantics. - RELAY_DEPLOY_TIMEOUT_MS now exceeds a first install AND its follow-up rebuild (2 x NATIVE_DEPS_INSTALL_TIMEOUT_MS + headroom) so a legitimate install-then-rebuild is not falsely timed out mid-repair. - shellEscape the two POSIX probe scripts instead of raw single-quoting so a future edit adding a quote can't silently break the node -e probe. Adds regression coverage for degraded-launch-on-repair-throw, degraded-launch when the repair lock can't be acquired, and the widened deploy-timeout bound. Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Probe node-pty's actual Windows binding, reset broken package trees before repair, and keep degraded relays retryable after self-heal. Use atomic FileMode.CreateNew locks under Windows PowerShell 5.1 and cover lock races and platform-specific system SSH behavior.
Co-authored-by: Orca <[email protected]>
94687d9 to
be32a8a
Compare
Co-authored-by: Orca <[email protected]> Co-authored-by: Neil <[email protected]> Co-authored-by: Jinwoo-H <[email protected]> Co-authored-by: Jinwoo Hong <[email protected]>
Summary
Remote terminals could fail with "node-pty is not available on this remote host" after an Orca update on hosts whose npm is configured to skip lifecycle scripts (
NPM_CONFIG_IGNORE_SCRIPTS=true, orignore-scripts=truein~/.npmrc). This makes the relay's native-dependency install detect and repair that state, and makes the repair path safe so it can never leave a user worse off than before.Original fix by @geelen; repair-safety hardening added while taking the PR over.
Root cause
The relay installs two native addons on the remote host —
node-ptyand@parcel/watcher. When the remote npm config ignores lifecycle scripts,npm installlands the JS on disk but never buildsnode-pty's native binding. The old health/probe checks usedrequire.resolve("node-pty"), which only checks that the JS entrypoint resolves — it passes even when the native.nodebinding is absent. Orca therefore considered the install healthy, and the relay's runtimerequire("node-pty")threw at PTY-spawn time.Reproduced locally (npm 11.16.0):
NPM_CONFIG_IGNORE_SCRIPTS=true)npm installrequire.resolvestill passesnpm install --ignore-scripts=false.npmrcnpm rebuild --ignore-scripts=false <pkg>What changed
Base fix
require()of both addons (notrequire.resolve()), so a present-but-unloadable binding is caught.npm install/npm rebuildpass--ignore-scripts=falseto force lifecycle scripts even when the host env / npmrc disables them.npm rebuild --ignore-scripts=falseand re-probe before the relay launches.Hardening (takeover)
require.resolve(which passed for a broken binding), newly making repair fatal would have been a straight regression for offline / no-toolchain hosts. The fresh-install path keeps its fatal semantics (no relay to launch yet).node -eprobe scripts go throughshellEscapeso a future edit can't silently break the-equoting.Evidence
--ignore-scripts=falseoverride (beats both the env var and project.npmrc), andnpm rebuildrepairing an already-present package.ssh-relay-native-deps-install.test.ts+ssh-relay-deploy.test.tspass. Added coverage: realrequire()health check,--ignore-scripts=falseon install + rebuild, automatic rebuild→re-probe recovery, post-rebuild re-probe SSH-failure propagation, degraded launch on repair-throw, degraded launch when the repair lock can't be acquired, and the widened deploy-timeout bound. Fullsrc/main/sshsuite: 676 passing / 2 skipped; typecheck + oxlint clean.ELI5
Orca drops a tiny helper on the remote machine so your terminals work there. The helper needs a special part (
node-pty) that has to be built on the remote host. Some locked-down machines are set up to skip "build steps" during installs — so the part got copied but never built. Orca's old check only asked "is the file there?" (yes) instead of "does it actually work?" (no), so it thought all was well and then terminals broke.Now Orca asks the real question ("does it load?"), tells npm to build it anyway, and if it's still broken, tries a rebuild. And if the remote genuinely can't build it, Orca still connects you (you just won't get remote terminals) instead of refusing to connect at all.
User-facing regression list
No availability regressions — everything that connected before still connects, and the previously-broken ignore-scripts case now works. The minor, non-blocking tradeoffs of the non-fatal design, stated honestly:
node-pty(no compiler / no prebuild for its arch) and already has a completed relay re-attempts a repair each reconnect (a no-opnpm install+ anode-gyprebuild that fails — usually in seconds) before launching degraded. Before, it reconnected fast with a silently-broken PTY. This is non-fatal, bounded, and self-heals the instant the host gains a toolchain (the rebuild then succeeds). Deliberately not memoized with a skip-marker here — an on-disk marker risked stranding transient failures; a session/TTL memo is a reasonable follow-up.@parcel/watcher-only load failure is still tagged[NPTY-MISSING](cosmetic — the stderr breadcrumb disambiguates), and the Windows probe doesn't capture stderr for that diagnostic.npm installis a no-op), and it self-heals on retry.Testing
pnpm typecheck— cleanpnpm lint(oxlint) — clean on touched filespnpm test—src/main/sshsuite 676 pass / 2 skip--ignore-scripts=false/npm rebuildmechanism reproduced on npm 11.16.0Security
Dependency names come from a fixed constant and go through the existing POSIX
shellEscape/ PowerShell literal helpers; no user-controlled package names, new dependencies, auth, secrets, or IPC surfaces. Native-load failures expose only bounded stdout/stderr tails in existing diagnostic logs.