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

inject NODE_OPTIONS will cause Node 10.x crash when fork child process #769

Closed
atian25 opened this issue Sep 24, 2020 · 13 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded

Comments

@atian25
Copy link

atian25 commented Sep 24, 2020

Describe the bug

some users of our project report an issue, when running cnpm install at vscode, it will crash.

Error: Command failed: /Users/sunny/Documents/Workspace/My/dingtalk-robot-server/node_modules/node/bin/node -e "process.stdout.write(JSON.stringify(process.versions))"
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '"/Users/sunny/Library/Application'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
$ echo ${NODE_OPTIONS}
--require "/Users/sunny/Library/Application Support/Code/User/workspaceStorage/0566b62ed6c96028f6eca701b9ac9d1e/ms-vscode.js-debug/bootloader.js"

To Reproduce
Steps to reproduce the behavior:

after a long dig, we found it seems a bug of Node 10.x

see https://github.com/atian25/node-bug-report

just a notify for you, free to close this issue.

Log File

VS Code Version: Replace me!

Additional context
Add any other context about the problem here.

@atian25 atian25 added the bug Issue identified by VS Code Team member as probable bug label Sep 24, 2020
@connor4312
Copy link
Member

We only will quote the path if we see Node 12 or higher on your PATH. I see that your Node binary is actually set to node_modules/node/bin/node, which is weird. How do you get that setup, do you use a version manager for this?

You can set nodeVersonHint: 10 in your launch.json with the nightly build to override/set the detected version.

@iFwu
Copy link
Contributor

iFwu commented Sep 24, 2020

@iFwu
Copy link
Contributor

iFwu commented Sep 24, 2020

Change Node.js version lower than 12 in PATH without re-toggling the autoAttachFilter option will cause this issue.

@atian25
Copy link
Author

atian25 commented Sep 24, 2020

@connor4312 it just a showcase for us to report the issue.

in our case, the user just open vscode terminal (when their global node version is 10.x), then exec cnpm install which will fork a child process, then they crash.

it's not about something like debug and launch.json.

@connor4312
Copy link
Member

When their global Node version is 10, we will detect that and format arguments correctly for Node 10.

@atian25
Copy link
Author

atian25 commented Sep 25, 2020

got, but at our use-case, the node version comes with the project itself.

just using something like npm install node --save

and when exec npm run some-scripts the node_modules/.bin will auto attach to PATH, so the execPath is target to special node.

@connor4312
Copy link
Member

Thanks for the info. I think I will add some logic to our binary provider to try to detect that case.

@connor4312
Copy link
Member

This will be fixed in the next nightly build; when running an npm script we will now prepend node_modules/.bin to the path for discovery.

@connor4312 connor4312 added this to the September 2020 milestone Sep 25, 2020
@atian25
Copy link
Author

atian25 commented Sep 25, 2020

could you add cnpm and tnpm to the package manager list? it's the most popular fork of npm at china due to the GFW.

@connor4312
Copy link
Member

Done 👍

@iFwu
Copy link
Contributor

iFwu commented Sep 27, 2020

@connor4312 I think there's still a problem after switching the node version to v10 without changing the autoAttachFilter flag. Do I need to open another issue for it?

@connor4312
Copy link
Member

Auto attach is a separate issue... but I'm not sure there's any action we will want to take for that. The large majority of users are on Node 12 or higher, and those that aren't generally don't downgrade to 10. We are also not able to detect a downgrade without actively polling, which I would really want to avoid.

@roblourens roblourens added the verified Verification succeeded label Oct 2, 2020
richardlau pushed a commit to nodejs/node that referenced this issue Oct 7, 2020
The characters specified within NODE_OPTIONS can now be escaped, which
is handy especially in conjunction with `--require` (where the file path
might happen to contain spaces that shouldn't cause the option to be
split into two).

Fixes: #12971

PR-URL: #24065
Backport-PR-URL: #35342
Reviewed-By: Anna Henningsen <[email protected]>

Refs: microsoft/vscode-js-debug#769
@rickyes
Copy link

rickyes commented Oct 10, 2020

Paths containing spaces and double quotes are already supported in Node.js v10, Release PR: nodejs/node#35544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants