Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-pty freezes when using pty.spawn under the VS Code debugger on Windows #640

Closed
ten4dinosaur opened this issue Nov 17, 2023 · 2 comments

Comments

@ten4dinosaur
Copy link

Environment details

  • OS: Windows
  • OS version: 10.0.19044.2604
  • node-pty version: 1.0.0
  • node version: 18.16.0
  • VS Code version: 1.84.2

Issue description

When running the example snippet from the node-pty documentation under the VS Code debugger, my script freezes on the call to pty.spawn.
const ptyProcess = pty.spawn(shell, [], { name: 'xterm-color', cols: 80, rows: 30, cwd: process.env.HOME, env: process.env });

Through some investigation, it appears this issue is related to the use of conpty. The exact line where the freeze occurs is in windowsPtyAgent.js:
var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, function (c) { return _this._$onProcessExit(c); });

Interestingly, if a breakpoint is set on this line, the script will continue execution normally after the breakpoint is hit and the program is resumed. The script also runs without any problems when the VS Code debugger is not used.

As a temporary workaround, the freezing issue can be mitigated by disabling conpty when running under debugger by useConpty in the options passed to the pty.spawn function. However, this is not an ideal fix as it prevents the usage of conpty.
useConpty: inspector.url() !== undefined ? false : undefined,

@ColinMcNeil
Copy link

Seeing this as well. Works fine when built, but hangs in the debugger.

@Tyriar
Copy link
Member

Tyriar commented Dec 17, 2024

Closing since we're moving towards shipping our own version of the conpty dll which should hopefully fix this #490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants