Skip to content

fix(relay): resolve packaged node-pty from resources - #20871

Closed
Jinwoo-H wants to merge 0 commit into
mainfrom
node-pty-issue
Closed

Jinwoo-H wants to merge 0 commit into
mainfrom
node-pty-issue

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7

Problem

Packaged Windows SSH relays could not start remote terminals when the normal node-pty load failed. The fallback resolver searched only Resources/relay/node_modules/node-pty, while packaged runtime dependencies are copied to the sibling Resources/node_modules/node-pty directory.

Fix

Resolve the packaged node-pty installation through process.resourcesPath/node_modules/node-pty, retaining the relay-local path for development bundles.

Fixes STA-7343

Validation

  • Relay PTY and subprocess tests: 32 passed
  • Node typecheck passed
  • Changed-code quality gate passed
  • Relay builds passed for Linux x64/arm64, macOS x64/arm64, Windows x64/arm64, and WSL
  • Live Windows 11 managed terminal verified (win32 x64)

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f8eedb61-c4cb-4f66-913d-be256194f711

📥 Commits

Reviewing files that changed from the base of the PR and between 2dfdbc8 and 08c5400.

📒 Files selected for processing (1)
  • src/relay/pty-handler.ts

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


📝 Walkthrough

Walkthrough

relayNodePtyDir now checks the packaged Resources/node_modules/node-pty directory when process.resourcesPath is set and the directory exists. If the packaged directory is unavailable, it returns the existing development path based on __dirname.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 08c54

The PR addresses packaged Windows terminal startup without an identified remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: resolving packaged node-pty from the relay resources path.
Description check ✅ Passed The description explains the problem, fix, linked issue, and validation results. It is focused and mostly complete, but it does not include the template headings or explicitly state N/A for visual p…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 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.

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

Important

The added branch keys off process.resourcesPath, and I could not find that set anywhere the relay actually runs. If the relay only ever executes remotely under a host-discovered plain node, this branch is inert and the reported failure has another cause. Please point at the launcher that sets it, or add a test that pins the selection.

Reviewed changes

  • Prefer packaged node-pty — relayNodePtyDir() now returns process.resourcesPath/node_modules/node-pty when process.resourcesPath is a string and that directory exists, otherwise the pre-existing join(__dirname, 'node_modules', 'node-pty') (src/relay/pty-handler.ts:647).

⚠️ The new branch may never execute for the relay

process.resourcesPath is set by Electron, but the relay bundle is deployed to a remote host and launched with a host-discovered plain node, where process.resourcesPath is undefined. If that is the only production path, packagedDir is always '' and the change is a no-op — meaning the Windows failure it targets would need a different fix. Resources/node_modules/node-pty itself is genuine, so the path is right; the open question is reachability.

Technical details
# Reachability of the packaged node-pty branch

## Affected sites
- `src/relay/relay-runtime-services.ts:46` — the only non-test `new PtyHandler(...)`, reached only via `src/relay/relay-daemon.ts` ← `src/relay/relay.ts`.
- `src/main/ssh/ssh-relay-deploy.ts:1802` — POSIX launch `nohup ${escapedNode} relay.js --detached ...`.
- `src/main/ssh/ssh-relay-deploy.ts:2155` — Windows PowerShell launch `& ${nodePath} relay.js --connect ...`.
- `src/main/ssh/ssh-remote-node-resolution.ts` — `nodePath` comes from the remote probe, never `process.execPath`.
- `config/scripts/build-relay.mjs:35,109-135` — `relay.js` is a standalone CJS bundle (`electron`/`node-pty` external), not an Electron `out/main` input.
- `src/main/ipc/parcel-watcher-entry-path.ts:48` — `ELECTRON_RUN_AS_NODE` children do expose `resourcesPath`, but no relay/`PtyHandler` child is launched that way.
- `config/packaged-runtime-node-modules.cjs:24,211-216` and `src/main/daemon/daemon-host-relocation.ts:183` — confirm `Resources/node_modules/node-pty` is the real packaged location, so the path itself is correct.

## Required outcome
- Identify the launcher/configuration under which the relay process has `process.resourcesPath` set, or state that this is an intentional defensive fallback and name the actual cause of the remote Windows failure.
- A test that stubs `process.resourcesPath` and `__dirname` and asserts the selected candidate would pin the selection logic regardless.

## Open question for the human
- Did the Windows 11 reproduction actually exercise the disk fallback (normal `import('node-pty')` failing), or verify only that terminals start? A healthy import never reaches `relayNodePtyDir()`.

ℹ️ Nitpicks

  • The new comment describes the __dirname fallback as what "development bundles" use, but config/scripts/build-relay.mjs stages no node_modules beside relay.js; that path is really the deployed remote relay layout (the relay dir owns node_modules or a symlink to the shared native-deps cache). Worth rewording so the intent stays clear.
  • No test pins the new branch, so the resourcesPath present/absent behavior can regress unnoticed.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

This branch was previously deployed

1 inactive deployment
adhoc-mac-build — 62c5037c Deployed Sep 15, 2026 by nwparker via build-hourly-win / build-win #1064
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.

2 participants