-
Notifications
You must be signed in to change notification settings - Fork 381
Turn off shell by default #2306
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
base: main
Are you sure you want to change the base?
Conversation
…e-dotnet-runtime into nagilson-no-shell
some of these are not necessary bc they should only run on unix but you never know
|
Ah so only spawn has boolean|string for shell, not exec.... facepalm |
only spawn can use shell = false spawn uses the direct string. escaping with " " causes it to not find the executable. need to confirm with weird path names that caused issues before but program files seems to work. setx "" parsing also no longer functions properly. noticed that --list-sdks --arch is missing the arch value so fixed that as well
I don't believe we ever use that.
| return []; | ||
| } | ||
|
|
||
| const findSDKsCommand = CommandExecutor.makeCommand(`"${existingPath}"`, ['--list-sdks', '--arch', requestedArchitecture]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break Linux/Mac scenarios in the shell? I think we need to look at this from a broader context.
| options.shell ??= true; | ||
| options.shell ??= os.platform() === 'win32' ? false : true; | ||
| // ^ Windows systemcalls (node.js process library uses process_wrap which uses process.cc which makes system calls) | ||
| // Windows seems to resolve the PATH by default in a system call. Unix system calls do not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just respect shell and let the shell do this?
What's this
This turns off the 'shell' when running commands for us in vscode. This provides a huge performance boost.
CICD Logs with Spawn:
--info 27.90. 29.21. 26.21. 2.68. (error) 27.
--list-runtimes 30.39. 2.32. (error) 31.
Without Spawn:
--list-runtimes 50. 45. 32 (error).
--info: 46. 41. 32. (error)
Explanation and Context
When spawning a process in node.js, it uses a shell. The shell takes a lot of time. The shell defaults:
Windows Default:
process.env.ComSpecorcmd.exeif undefined.Unix Default:
/bin/shHere's what doesn't work without a shell:
&(To make a background process)/* ?Globbing to get wild cards> << >RedirectionI/O|Piping - Chain 1 command output to the next.Shell Environment Variablesthat aren't set on the system but instead a profile that's launched with the SHELL"file"escaping.process.envis used as env by default regardless of shell.Now, here's a rough list of everything we call:
Fun part:
process.spawnmakes a system call.https://github.com/nodejs/node/blob/5fe78006834011621969a76b4f2d98c0e0039b33/deps/uv/src/unix/process.c#L966
https://github.com/nodejs/node/blob/5fe78006834011621969a76b4f2d98c0e0039b33/src/process_wrap.cc#L348C13-L348C21
https://github.com/nodejs/node/blob/5fe78006834011621969a76b4f2d98c0e0039b33/src/env_properties.h#L171
It looks like system calls on Windows resolve the PATH by default without a shell, but they do not on Unix.
Node process uses
CreateProcessWandexecve.Windows:
CreateProcessA function (processthreadsapi.h) - Win32 apps | Microsoft Learn
“The directories that are listed in the PATH environment variable [are searched].”
https://github.com/libuv/libuv/blob/b00c5d1a09c094020044e79e19f478a25b8e1431/src/win/process.c#L1067
Unix:
execve(2) - Linux manual page
[Use other] standardised variants of this function provided by libc, including ones that search the PATH environment variable.