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

js-debug insists on recent version of node.js #111642

Closed
weinand opened this issue Dec 1, 2020 · 8 comments
Closed

js-debug insists on recent version of node.js #111642

weinand opened this issue Dec 1, 2020 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Dec 1, 2020

Testing #111422

This launch config (which doesn't use node.js at all):

{
	"type": "node",
	"request": "launch",
	"name": "Launch Program",
	"runtimeExecutable": "echo",
	"runtimeArgs": [
		"${env.FOO}",
		"${env.PATH}"
	]
}

does not work on a linux that only has node.js 5.0.

Error message:

2020-12-01_17-27-15

The launch config works fine when setting debug.javascript.usePreview to false.

(I use "nvm" on that linux and have it configured for node.js "12.13.1" but js-debug doesn't find it on the PATH, but that is a different issue...)

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Dec 1, 2020
@connor4312
Copy link
Member

Node versions before 7 use the old inspector protocol rather than CDP, which we don't support, and the protocol is somewhat buggy even on 8. Node 8, which is EOL since this beginning of this year, accounts for <1.2% of debug users, and I imagine there are even fewer users with previous node versions, so I don't think it's worth going to the effort of trying to support this in any way aside from providing the informative prompt.

@weinand
Copy link
Contributor Author

weinand commented Dec 1, 2020

@connor4312 I'm not asking for support for legacy versions of node.js here.

The problem is that js-debug eagerly blocks my launch config based on the false assumption that it will use /usr/local/bin/node. But the launch config does not use node.js at all. So there is no reason for blocking it. I think the error should only be shown if js-debug detects a real problem where there is some probability that an old version of node.js might be the culprit.

In my case I'm using a standard ubuntu (which seems to have node.js 5.0 installed). But since I'm using "nvm", I do not really care about the old node.js 5.0 install. Whenever I run node.js it picks up the correct "nvm-installed" version. Only js-debug seems to find the legacy version.

@connor4312
Copy link
Member

But the launch config does not use node.js at all. So there is no reason for blocking it. I think the error should only be shown if js-debug detects a real problem where there is some probability that an old version of node.js might be the culprit.

js-debug does not know that the launch won't eventually use Node.js; we support debugging nested processes in the tree. In theory we could allowlist certain commands that don't have side effects like "echo" or "cat", but I don't know why users would want to have a node launch config that doesn't use Node...

On 6 and below we get a syntax error trying to import the bootloader. If the process is not running in an integrated or external terminal, we could catch the syntax error from stderr, but in a terminal we would have no way to know what happened and be stuck waiting for the connection.

Whenever I run node.js it picks up the correct "nvm-installed" version. Only js-debug seems to find the legacy version.

We pull node from the PATH of the extension host both for version detection and actually running the program. If the nvm version of the binary isn't in the extension host, that is a problem. It may be related to #106537

@connor4312
Copy link
Member

One thing I thought of is checking process.version in the bootloader and just echo'ing the warning to the console if the version is too low. However this has two downsides:

  • it would not show in the debug console (unless we do more work there...) because we don't emit stdout by default
  • --require in NODE_OPTIONS does not work on Node 4 or below, so that would at best be a partial solution for 5 and 6

@weinand
Copy link
Contributor Author

weinand commented Dec 7, 2020

@connor4312 thanks a lot for exploring this...

But again, I'm actually not asking for supporting node.js 5.x (or other obsolete versions).
Couldn't you just turn the fatal error (which blocks debugging completely) into a warning (that doesn't prevent me from debugging)?

Imagine I have shell script that uses a version 12.13.1 of node.js and hardcodes an absolute path to it.
On my system (e.g. Ubuntu) I still have the distribution's default version of node.js installed (e.g. version < 8.0).
But I'm never using this version, but I didn't bother to remove it either.

If I now create a debug config that uses the shell script from above as the "runtimeExecutable", js-debug will prevent me from debugging this perfectly fine setup because it finds the obsolete version of node.

@connor4312
Copy link
Member

I think that's fair. I will now show this instead.

@connor4312 connor4312 added this to the December/January 2021 milestone Dec 7, 2020
@connor4312 connor4312 added the bug Issue identified by VS Code Team member as probable bug label Dec 7, 2020
@weinand
Copy link
Contributor Author

weinand commented Dec 7, 2020

@connor4312 perfect, thanks a lot!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2021
@weinand
Copy link
Contributor Author

weinand commented Jan 27, 2021

cool, js-debug no longer prevents me from debugging:

2021-01-27_11-05-58

@weinand weinand added the verified Verification succeeded label Jan 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

2 participants