Skip to content

Support loading prebuilt binary from NODE_PTY_PREBUILT_PATH#912

Closed
anthonykim1 wants to merge 1 commit intomainfrom
anthonykim1/envVarPBbinary
Closed

Support loading prebuilt binary from NODE_PTY_PREBUILT_PATH#912
anthonykim1 wants to merge 1 commit intomainfrom
anthonykim1/envVarPBbinary

Conversation

@anthonykim1
Copy link
Copy Markdown
Contributor

@anthonykim1 anthonykim1 commented Apr 6, 2026

Part of: microsoft/vscode#307746

Adds NODE_PTY_PREBUILT_PATH env var — if set, loadNativeModule()
tries that directory first before the usual build/Releaseprebuilds/
fallback.

Chat extension bundles copilot sdk, which in turn bundles node-pty with
its own prebuilds. Extension's current workaround is finding vscode's
pty.node at runtime and copying it on top of the sdk's prebuilds dir.

---> nodePtyShim has a bunch of retry loops and polling because the copy can
race. This won't be great if chat moves into core — now we're copying
files inside our own install directory at startup, code signing issues, etc

@anthonykim1 anthonykim1 self-assigned this Apr 6, 2026
@anthonykim1 anthonykim1 added this to the 1.115.0 milestone Apr 6, 2026
@anthonykim1
Copy link
Copy Markdown
Contributor Author

@deepak1556 Could I get your eye on this please?

@anthonykim1 anthonykim1 modified the milestones: 1.115.0, 1.116.0 Apr 6, 2026
@anthonykim1 anthonykim1 marked this pull request as ready for review April 6, 2026 07:47
Copy link
Copy Markdown
Contributor

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an env way to inject native binding from arbitrary paths is not a good design, it just opens up as easy target to load any binding into the process.

IIUC the motivation is avoid runtime copy of the node-pty module for the sdk when bundled as part of the core. In which case, could you rather remove the node-pty package from sdk during build time, then allow the module to be auto resolved via Node.js default module resolution. If the sdk is part of core, it should eventually end up resolving the module from resources/app/node_modules. Have you confirmed if this is possible ?

@anthonykim1
Copy link
Copy Markdown
Contributor Author

anthonykim1 commented Apr 6, 2026

@deepak1556 Thanks, that sounds neat for vscode. This would allow us to not change anything from node-pty side.

For other non-vscode consumers of copilot sdk though:
I don't think copilot cli declares node-pty as dependency but rather just bundles pre-built binary. If we were to remove this from build time, then other non-vscode consumer of copilot sdk might fail when copilot sdk code runs require('node-pty'). Maybe we could have special casing that removes it only for vscode?

/cc @rebornix @DonJayamanne @devm33 please correct me for copilot cli sdk matter.

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.

3 participants