Skip to content

fix(relay): name why node-pty could not load, instead of guessing four causes at once - #17891

Merged
nwparker merged 1 commit into
mainfrom
fix/node-pty-load-failure-diagnosis
Sep 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/node-pty-load-failure-diagnosis

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​473 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​454
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​903 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​815

The real error was being destroyed three times over

formatNodePtyUnavailableMessage hedges four causes in one paragraph, and the comment at pty-handler.ts:106 concedes why: "The relay only sees an unloadable binding, never why." That turned out to be three separate losses:

  1. loadPtyUncached had two bare catch {} blocks. Both the import('node-pty') error and the require(moduleEntry) error were dropped on the floor; the function returned null and the caller threw the static paragraph. This is the primary loss.
  2. The spawn catch used the error as a boolean and discarded it — if (isMissingNodePtyNativeBinding(error)) { throw new Error(formatNodePtyUnavailableMessage(...)) }.
  3. node-pty itself destroys it upstream of both. loadNativeModule walks build/Release, build/Debug, prebuilds/<platform>-<arch> and rethrows only the last error. So the GLIBC/ABI/arch sentence from build/Release is already gone before the relay sees anything — what arrives is Cannot find module '../prebuilds/linux-x64//pty.node'. Acting on that text sends the user to install a module that is already installed.

Recovering the real message needs a separate dlopen of the file the loader would have opened. That is done out of process, so a binding that aborts inside the loader cannot take the relay down. Verified end-to-end against a deliberately corrupt pty.node: the raw message came back as dlopen(…/build/Release/pty.node, 0x0001): tried: '…' (slice is not valid mach-o file) — exactly the text node-pty had replaced with Cannot find module.

Nine classifications, each with required evidence

Reason Evidence
toolchain_missing No binding in any of the three dirs and the /bin/sh probe reports make / C++ / python3 missing (Linux only)
dependency_missing No binding anywhere, toolchain present or N/A
abi_mismatch NODE_MODULE_VERSION x … y in the recovered message, or config.gypi's node_module_version ≠ process.versions.modules
arch_mismatch incompatible architecture, invalid ELF header, wrong ELF class, Exec format error, or config.gypi's target_arch ≠ process.arch
libc_floor GLIBC_x.y' not found / GLIBCXX_ / CXXABI_; names both the required version and the host's actual glibc from process.report
shared_library_missing libfoo.so.N: cannot open shared object file; kept separate from libc_floor because one is an install and the other a rebuild
load_crashed The out-of-process probe was killed by a signal — the uncatchable case
load_failed Binding present, loader answered, nothing recognized; quotes the loader verbatim
unverifiable Probe timed out / could not start / dir unreadable. Diagnoses nothing, prescribes only a retry, per ssh-execution-boundary.md

A loader message that named the fault outranks the build record; load_failed and dependency_missing do not, so config.gypi is still consulted when node-pty flattened the error away.

Sample output:

Remote terminals are unavailable: the binary requires GLIBC_2.34, which this host's C library does not
provide (glibc 2.31). The binding was compiled on a newer system than this one. Reconnect to rebuild
node-pty here; Orca's own Linux floor is glibc 2.31.
Host: linux/x64, glibc 2.31, Node v20.11.0 (ABI 115), prebuild slot linux-x64-glibc.

The recovery finding

repairInstalledNativeDeps already auto-recovers an ABI mismatch — but only on the client, at connect time, and there is no path from the relay's spawn-time failure to it. nativeDepsProbeJs does require("node-pty") + loadNativeModule, so a mismatched binding fails that probe and installNativeDeps(..., resetDeps: ['node-pty']) recompiles it.

So reconnecting genuinely does fix the ABI class today — the old message just buried that instruction among three others so the user could not tell which one would work.

Landed: the structured cause on the wire. src/shared/terminal-unavailable-cause.ts, a zod-validated optional data field on the existing JSON-RPC error, through the same allowlist gate skill_install_failure already uses. Rule 1 additive; an old client ignores it and renders today's message. reason is deliberately string, not an enum, so a newer relay naming a fault this client never heard of does not cause the whole cause — including repairable — to be dropped. Tested round-tripping through the dispatcher, including that a malformed cause is dropped entirely rather than half-read.

repairable is true only for abi_mismatch, arch_mismatch, libc_floor, load_crashed, dependency_missing, and only when the toolchain is not known-missing — the relay's node-pty is compiled on the remote, so a binding that no longer matches the machine is fixed by recompiling there. (That is why libc_floor is recoverable here even though the packaging floor is binding elsewhere: that doc constrains binaries built on our runners, not ones compiled on the host.) toolchain_missing and shared_library_missing are false — the rebuild needs the very thing that is absent. mayRepairFromCause re-derives all of this client-side rather than trusting a peer's flag (#14830).

Deliberately not landed: the client-side repair routing. The seam is ssh-agent-session-create-operation.ts:67 → ssh-pty-provider.ts, but repairInstalledNativeDeps needs an SshConnection, remote dir, node path and the repair lock — all owned by ssh-relay-deploy.ts / ssh-relay-session.ts — plus a reconnect. Two reasons to stop: it touches session lifecycle, and #17817 is not merged into this branch, where probeRequiredNativeDeps is still two-state with the catch { available: false, missing: ALL } that #17817 fixes. Building repair routing on that function now would collide. Handoff: read error.data at that seam, gate on mayRepairFromCause, route into repairInstalledNativeDeps, reconnect once.

No relay-side rebuild. Considered and rejected: the client's repair path takes tryAcquireRelayRepairLock before touching node_modules, and a relay rebuilding without that lock could collide with a concurrent reconnect's repair. All node_modules mutation stays on the locked client side. No retry loop, no per-spawn rebuild, nothing that runs while PTYs are live.

Does this fix #17830's reporter?

Not fully determinable from the issue, and I would rather say so than claim it. The report has no remote OS, no remote Node version, no relay log — only the message text and the Windows client's details.

What is true: they now get one named cause instead of four hedged ones, plus the remote's platform, arch, glibc and Node ABI on the message — which makes the issue actionable even in the worst case. The likely causes for "Linux remote, failed at first link" are toolchain_missing (compile skipped) or abi_mismatch; the first now yields an exact apt-get line, the second states both ABI numbers and "reconnect to rebuild", which the existing deploy-time repair does perform.

So: a message naming the exact cause and a step that works. Full hands-off recovery needs the client-side routing above.

Verification

52 passed across the four affected relay test files
8183 passed across src/relay src/main/orcad src/shared

Before, against pre-change code:

AssertionError: expected 'Remote terminals are unavailable: nod…' to contain
  'Failed to load native module: conpty.node, checked: build/Release, prebuilds/win32-x64'

Two pre-existing flakes surfaced in full-suite runs and were confirmed to fail on a clean tree too: automation-change-publication.test.ts (28.7s against a 30s timeout) and remote-runtime-shared-control-connection.test.ts (~3 runs in 4, with and without this change).

Refs #17830


ELI5

When the remote could not load its terminal library, Orca showed one paragraph guessing at four possible causes. It could not do better because the real error was being thrown away three separate times — including by the library itself, which reports only the last of the three places it looked.

User-facing regression risk

  • The error message text changes substantially. Anything matching on the old string will not match.
  • On the failure path only, Orca now runs one short out-of-process probe to recover the real loader error. It is bounded and cannot take the relay down, but it is one extra process spawn when a spawn has already failed.
  • Honest: whether [Bug]: Remote terminals are unavailable #17830's specific reporter is fixed is not determinable from their issue — it has no remote OS, Node version, or log. They will get one named cause plus host details, which makes it actionable either way.

The relay could only say "terminals are unavailable" and then list three
remedies for four different faults, none of which the user could verify
(#17830). Two things were destroying the evidence:

- `loadPtyUncached` caught the load error into bare `catch {}` blocks
  (pty-handler.ts:539, :551) and returned null. The only cause anyone had
  was discarded on the spot.
- node-pty's own loader walks three directories and rethrows only the LAST
  failure, so even an uncaught error arrives as `Cannot find module
  '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone.

The relay now keeps the load error, recovers the real dlopen message with an
out-of-process load of the file node-pty would have opened, reads what
node-gyp configured the binding for (`build/config.gypi`), captures the
host's Node ABI, arch and glibc, and probes the toolchain only when nothing
was compiled. Each fault gets its own message naming values the user can
check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch,
libc_floor, shared_library_missing, load_crashed, and load_failed which
quotes the loader verbatim. A probe that did not answer stays `unverifiable`
and prescribes nothing.

The classification is now also structured data on the error, so a client can
repair the host instead of printing a paragraph: an additive, schema-validated
`data` field on an existing JSON-RPC error, with `repairable` true only for a
proved fault that recompiling on the host actually fixes.

Reuses orcad's loader-message parsers and out-of-process probe rather than
adding a second copy; `classifyLoaderMessage` moves to a shared module and
gains architecture and missing-shared-library cases, which the orcad boot
precondition picks up too.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds native loader parsers and node-pty loader classification. It separates probe outcome reading from probe diagnosis. The relay now surveys bindings, build records, loader results, and Linux toolchains to produce structured terminal-unavailability causes. The PTY handler includes diagnosis-driven messages and RPC error data. The dispatcher validates and forwards terminal causes. Tests cover loader parsing, probe classification, evidence collection, remediation messages, schema validation, and PTY error propagation.

Merge Risk: 🟡 Moderate · up to 36413

This PR replaces generic PTY failures with structured remote diagnostics, but some failures can still be misclassified or given the wrong remediation, while repeated failures can multiply diagnostic process work and expose host details to relay clients. These concrete correctness, runtime, and disclosure risks should be fixed or explicitly accepted before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 59.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed context, rationale, implementation scope, linked issue reference, testing results, and regression risks. However, it omits the required Visual Proof section and does … Add the required template sections, especially Visual Proof with before/after evidence or exactly N/A with a brief reason. Add or complete the Linked Issue, Review, Agent skill upstream boundary, Notes, and Checklist sections, including t…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses issue #17830 by preserving node-pty loader errors, identifying one evidence-based failure cause, including remote host details, and providing actionable remediation. The implementatio…
Out of Scope Changes check ✅ Passed The changes remain within scope. The added diagnosis logic, structured RPC error data, repairability metadata, and tests directly support the node-pty terminal-availability objective. Client-side repa…
Title check ✅ Passed The title clearly describes the main change: replacing guessed node-pty failure messages with specific diagnostics. It is concise and related to the changeset.
Full details: Linked Issues check

Explanation

The PR addresses issue #17830 by preserving node-pty loader errors, identifying one evidence-based failure cause, including remote host details, and providing actionable remediation. The implementation matches the stated diagnostic objective.

Full details: Out of Scope Changes check

Explanation

The changes remain within scope. The added diagnosis logic, structured RPC error data, repairability metadata, and tests directly support the node-pty terminal-availability objective. Client-side repair routing and relay-side rebuilding are explicitly excluded.

Full details: Description check

Explanation

The description provides detailed context, rationale, implementation scope, linked issue reference, testing results, and regression risks. However, it omits the required Visual Proof section and does not state N/A for this behavior change. Several template sections and checklist confirmations are also missing.

Resolution

Add the required template sections, especially Visual Proof with before/after evidence or exactly N/A with a brief reason. Add or complete the Linked Issue, Review, Agent skill upstream boundary, Notes, and Checklist sections, including the applicable testing and validation confirmations.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/relay/pty-handler.ts (1)

579-589: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Memoize the diagnosis so one broken host does not fork a probe per spawn attempt.

nodePtyUnavailableError runs the full survey on every rejected spawn. collectNodePtyUnavailableDiagnosis starts a child Node process with a 10 s timeout, and on Linux a second shell probe with a 5 s timeout.

spawnAfterAdmission runs inside the beginPtyCreation admission window. Each failing spawn therefore holds pendingSpawnCount for up to 10 s and delays its own rejection by the same amount. A client that restores several panes on connect produces one probe process per pane, up to MAX_RELAY_PTY_SESSIONS.

Cache the diagnosis promise and clear it when invalidatePtyModuleAfterBindingFailure runs, so a retry burst reuses one probe.

♻️ Proposed refactor
+  /** Reused across a retry burst: the probe costs a child process and up to 10s. */
+  private nodePtyDiagnosisPromise: Promise<NodePtyUnavailableDiagnosis> | null = null
+
   private async nodePtyUnavailableError(spawnError?: unknown): Promise<Error> {
     const nodePtyDir = this.relayNodePtyDir()
-    const diagnosis = await collectNodePtyUnavailableDiagnosis({
-      nodePtyDir: existsSync(nodePtyDir) ? nodePtyDir : null,
-      error: spawnError ?? this.lastPtyLoadError
-    })
+    this.nodePtyDiagnosisPromise ??= collectNodePtyUnavailableDiagnosis({
+      nodePtyDir: existsSync(nodePtyDir) ? nodePtyDir : null,
+      error: spawnError ?? this.lastPtyLoadError
+    })
+    const diagnosis = await this.nodePtyDiagnosisPromise
     return Object.assign(new Error(formatNodePtyUnavailableMessage(diagnosis)), {
       code: TERMINAL_UNAVAILABLE_RPC_ERROR_CODE,
       data: toTerminalUnavailableCause(diagnosis)
     })
   }
   private invalidatePtyModuleAfterBindingFailure(): void {
     this.ptyModule = null
     this.reloadPtyModuleFromDisk = true
+    // The host changed, so the cached verdict is no longer evidence.
+    this.nodePtyDiagnosisPromise = null

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 497e22bf-d7a6-4924-a8f0-767662023d80

📥 Commits

Reviewing files that changed from the base of the PR and between c475d23 and 3641310.

📒 Files selected for processing (14)
  • src/main/orcad/native-host-abi.test.ts
  • src/main/orcad/native-host-abi.ts
  • src/main/orcad/node-pty-loader-diagnosis.ts
  • src/main/orcad/node-pty-precondition.ts
  • src/relay/dispatcher-rpc-routing.ts
  • src/relay/dispatcher-structured-error.test.ts
  • src/relay/node-pty-binding-survey.test.ts
  • src/relay/node-pty-binding-survey.ts
  • src/relay/node-pty-unavailable-diagnosis.test.ts
  • src/relay/node-pty-unavailable-diagnosis.ts
  • src/relay/pty-handler-spawn-admission.test.ts
  • src/relay/pty-handler.ts
  • src/shared/runtime-capability-degradation.ts
  • src/shared/terminal-unavailable-cause.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

if (machO) {
return { built: machO[1], host: machO[2] }
}
if (/invalid ELF header|wrong ELF class|Exec format error|ELFCLASS(?:32|64)/.test(loaderError)) {

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not classify generic ELF-format failures as architecture mismatches.

invalid ELF header and Exec format error do not prove a CPU architecture mismatch. A corrupt or non-ELF pty.node follows this branch and produces the arch_mismatch message and architecture rebuild advice. Restrict this result to errors that identify an incompatible architecture or ELF class. Let the generic loader-failure path handle the other messages.

Proposed fix
-  if (/invalid ELF header|wrong ELF class|Exec format error|ELFCLASS(?:32|64)/.test(loaderError)) {
+  if (/wrong ELF class|ELFCLASS(?:32|64)/.test(loaderError)) {
     return { built: null, host: null }
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (/invalid ELF header|wrong ELF class|Exec format error|ELFCLASS(?:32|64)/.test(loaderError)) {
if (/wrong ELF class|ELFCLASS(?:32|64)/.test(loaderError)) {

Comment on lines +84 to +88
expect(diagnosis.status).toBe('blocked')
expect(diagnosis.rawError).toBeTruthy()
expect(isFlattenedNodePtyLoaderMessage(diagnosis.rawError!)).toBe(false)
expect(diagnosis.rawError).not.toBe(FLATTENED)
expect(diagnosis.rawError).toMatch(/pty\.node/)

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Two assertions require probe outcomes that the code treats as optional.

collectNodePtyUnavailableDiagnosis does not guarantee either value:

  • Lines 84-88: if the child process crashes while it opens the bogus pty.node, readNodePtyProbeOutcome returns signalled. diagnoseNodePtyUnavailable then sets no loaderError, so rawError falls back to the requireError, which is FLATTENED. Line 86 fails in that case. The sibling test at line 106 already accepts load_crashed, so this outcome is expected on some platforms.
  • Line 130: on Linux, probeRelayBuildToolchain returns null when /bin/sh cannot run or the probe times out. The assertion then fails for an environment reason, not a code defect.

Assert the recovered loader error only when a loader error was recovered, and treat a null toolchain on Linux as a probe that did not answer.

💚 Proposed fix
     expect(diagnosis.status).toBe('blocked')
-    expect(diagnosis.rawError).toBeTruthy()
-    expect(isFlattenedNodePtyLoaderMessage(diagnosis.rawError!)).toBe(false)
-    expect(diagnosis.rawError).not.toBe(FLATTENED)
-    expect(diagnosis.rawError).toMatch(/pty\.node/)
+    expect(diagnosis.rawError).toBeTruthy()
+    if (diagnosis.reason !== 'load_crashed') {
+      expect(isFlattenedNodePtyLoaderMessage(diagnosis.rawError!)).toBe(false)
+      expect(diagnosis.rawError).not.toBe(FLATTENED)
+      expect(diagnosis.rawError).toMatch(/pty\.node/)
+    }
-    expect(diagnosis.toolchain === null).toBe(process.platform !== 'linux')
+    // Non-Linux hosts ship a node-pty prebuild, so the toolchain is never probed there.
+    if (process.platform !== 'linux') {
+      expect(diagnosis.toolchain).toBeNull()
+    }

Also applies to: 130-130

Comment on lines +147 to +152
return {
...base,
status: 'blocked',
reason: classified?.reason ?? 'load_failed',
detail: classified?.detail ?? 'the binding is present but the loader refused it'
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Inspect the probe script and its reported-error reader.
set -euo pipefail
fd -t f 'node-pty-precondition.ts' -x cat -n {}
fd -t f 'node-pty-loader-diagnosis.ts' -x cat -n {}

Repository: stablyai/orca

Length of output: 21375


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- review conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print 2>/dev/null | sort | while read -r f; do
  printf '\n--- %s ---\n' "$f"
  head -80 "$f"
done
printf '%s\n' '--- directly bound diagnosis definitions ---'
cat -n src/relay/node-pty-unavailable-diagnosis.ts | sed -n '1,220p'
printf '%s\n' '--- loader diagnosis callers and remedy contract ---'
rg -n -C 8 'collectNodePtyUnavailableDiagnosis|remedyFor|bindingPath|LOADER_NAMED_FAULTS|classifyNodePtyLoaderMessage' src shared

Repository: stablyai/orca

Length of output: 192


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print 2>/dev/null | sort | while read -r f; do
  printf '\n--- %s ---\n' "$f"
  head -80 "$f"
done
printf '%s\n' '--- diagnosis implementation ---'
cat -n src/relay/node-pty-unavailable-diagnosis.ts | sed -n '1,220p'
printf '%s\n' '--- directly bound callers and remedy contract ---'
rg -n -C 8 'collectNodePtyUnavailableDiagnosis|remedyFor|bindingPath|LOADER_NAMED_FAULTS|classifyNodePtyLoaderMessage' src shared

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- diagnosis control flow ---'
cat -n src/relay/node-pty-unavailable-diagnosis.ts | sed -n '75,190p'
printf '%s\n' '--- remedy and collector definitions ---'
rg -n -C 12 'function remedyFor|const remedyFor|remedyFor\(|collectNodePtyUnavailableDiagnosis|LOADER_NAMED_FAULTS' src/relay src/main

Repository: stablyai/orca

Length of output: 27468


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf '%s\n' '--- collector flow ---'
cat -n src/relay/node-pty-binding-survey.ts | sed -n '191,285p'
printf '%s\n' '--- remedies and cause mapping ---'
cat -n src/relay/node-pty-unavailable-diagnosis.ts | sed -n '280,380p'

Repository: stablyai/orca

Length of output: 6003


Map dependency_missing to load_failed when a binding is present.

classifyNodePtyLoaderMessage maps MODULE_NOT_FOUND and Cannot find module to dependency_missing. The binding-present branch preserves that reason, so remedyFor incorrectly reports no compiled binary and available build tools. The collector sets toolchain to null when bindingPath exists.

Comment on lines +49 to +50
toolchain_missing:
'Terminals are unavailable on this host: node-pty has no prebuilt binary for Linux and this host is missing the C/C++ build tools needed to compile one. Install them, then reconnect.',

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Localize the new terminal-unavailability messages.

Replace these new user-facing literals with intent-named localization IDs and named placeholders. This lets translated clients show actionable diagnostics.

Based on learnings: new user-facing TypeScript strings must use intent-named localization IDs with named interpolation placeholders.

Also applies to: 53-54

Source: Learnings

@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 critical issues — one minor suggestion inline on a message that overstates its evidence.

Reviewed changes

  • Out-of-process loader recovery — node-pty-binding-survey.ts surveys the binding on disk and runs a child-process dlopen probe to recover the loader message node-pty's own loader discards, so the relay names the real fault instead of a flattened Cannot find module.
  • Evidence-ordered diagnosis — node-pty-unavailable-diagnosis.ts classifies loader text, config.gypi build record, probe signals, and the toolchain probe into nine reasons with one remedy each, keeping unverifiable a first-class, non-prescriptive outcome.
  • Structured wire cause — terminal-unavailable-cause.ts publishes a zod-validated optional data field through the dispatcher's error allowlist, with repairable re-derived client-side via mayRepairFromCause; client repair routing is deliberately deferred to a follow-up.
  • Error preservation at the seam — PtyHandler retains lastPtyLoadError and routes both load- and spawn-time failures through the new diagnosis, replacing the old hedged paragraph.
  • New parsers and reason vocabulary — parseIncompatibleArchitecture and parseMissingSharedLibrary join native-host-abi.ts, with matching RuntimeTerminalUnavailableReason members and shared messages.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

case 'dependency_missing':
return (
`node-pty has no compiled binary on this host (${searchedPhrase(survey)}). ` +
`The C/C++ build tools needed to compile it are present, so reconnect to reinstall ` +

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.

This branch is also reached when toolchain is null — non-Linux hosts (where probeRelayBuildToolchain returns null without probing) and Linux hosts whose toolchain probe timed out or threw. In both cases the message asserts "the C/C++ build tools needed to compile it are present" without any evidence, which is the overclaim the unverifiable discipline this PR introduces is meant to rule out. Gate that clause on a completed probe (toolchain !== null && toolchain.toolchainMissing === false) and fall back to the neutral "reconnect to reinstall the relay's native modules" otherwise — the actionable remedy stays the same.

@nwparker
nwparker merged commit b552bcb into main Sep 2, 2026
33 checks passed
@nwparker
nwparker deleted the fix/node-pty-load-failure-diagnosis branch September 2, 2026 05:38
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
…tablyai#17891)

The relay could only say "terminals are unavailable" and then list three
remedies for four different faults, none of which the user could verify
(stablyai#17830). Two things were destroying the evidence:

- `loadPtyUncached` caught the load error into bare `catch {}` blocks
  (pty-handler.ts:539, :551) and returned null. The only cause anyone had
  was discarded on the spot.
- node-pty's own loader walks three directories and rethrows only the LAST
  failure, so even an uncaught error arrives as `Cannot find module
  '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone.

The relay now keeps the load error, recovers the real dlopen message with an
out-of-process load of the file node-pty would have opened, reads what
node-gyp configured the binding for (`build/config.gypi`), captures the
host's Node ABI, arch and glibc, and probes the toolchain only when nothing
was compiled. Each fault gets its own message naming values the user can
check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch,
libc_floor, shared_library_missing, load_crashed, and load_failed which
quotes the loader verbatim. A probe that did not answer stays `unverifiable`
and prescribes nothing.

The classification is now also structured data on the error, so a client can
repair the host instead of printing a paragraph: an additive, schema-validated
`data` field on an existing JSON-RPC error, with `repairable` true only for a
proved fault that recompiling on the host actually fixes.

Reuses orcad's loader-message parsers and out-of-process probe rather than
adding a second copy; `classifyLoaderMessage` moves to a shared module and
gains architecture and missing-shared-library cases, which the orcad boot
precondition picks up too.

Mirror-Of: b552bcb
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#17891)

The relay could only say "terminals are unavailable" and then list three
remedies for four different faults, none of which the user could verify
(stablyai#17830). Two things were destroying the evidence:

- `loadPtyUncached` caught the load error into bare `catch {}` blocks
  (pty-handler.ts:539, :551) and returned null. The only cause anyone had
  was discarded on the spot.
- node-pty's own loader walks three directories and rethrows only the LAST
  failure, so even an uncaught error arrives as `Cannot find module
  '../prebuilds/...'` — the GLIBC/ABI/arch sentence is already gone.

The relay now keeps the load error, recovers the real dlopen message with an
out-of-process load of the file node-pty would have opened, reads what
node-gyp configured the binding for (`build/config.gypi`), captures the
host's Node ABI, arch and glibc, and probes the toolchain only when nothing
was compiled. Each fault gets its own message naming values the user can
check: toolchain_missing, dependency_missing, abi_mismatch, arch_mismatch,
libc_floor, shared_library_missing, load_crashed, and load_failed which
quotes the loader verbatim. A probe that did not answer stays `unverifiable`
and prescribes nothing.

The classification is now also structured data on the error, so a client can
repair the host instead of printing a paragraph: an additive, schema-validated
`data` field on an existing JSON-RPC error, with `repairable` true only for a
proved fault that recompiling on the host actually fixes.

Reuses orcad's loader-message parsers and out-of-process probe rather than
adding a second copy; `classifyLoaderMessage` moves to a shared module and
gains architecture and missing-shared-library cases, which the orcad boot
precondition picks up too.
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.

[Bug]: Remote terminals are unavailable

1 participant