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

Unexpected behavior for execSync #54649

Closed
OrdinaryDude2634 opened this issue Aug 29, 2024 · 5 comments
Closed

Unexpected behavior for execSync #54649

OrdinaryDude2634 opened this issue Aug 29, 2024 · 5 comments
Labels
child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform.

Comments

@OrdinaryDude2634
Copy link

OrdinaryDude2634 commented Aug 29, 2024

Version

20.11.0

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

Child process

What steps will reproduce the bug?

execSync('net session', {windowsHide: true, stdio: ['ignore', 'ignore', 'pipe']}); should print stderr but it does not. as said in the documentation pipe is the default so changing stdio to pipe should not change anything but it stops stderr from printing, however do note it still throws the exception
this behavior is also present with ['pipe', 'pipe', 'pipe'] or any other variant

How often does it reproduce? Is there a required condition?

100% of the time. none as far as i know

What is the expected behavior? Why is that the expected behavior?

to print out stderr like it's supposed to, if you dont touch stdio it prints stderr but if you change it to pipe which is the default it dosent print stderr anymore, i do not know if it happens with stdin or stdout

What do you see instead?

nothing, explained above

Additional information

please do not forget about this:
there should be an option to not print the stderr but still keep the thrown exception detailed. if you set it to ignore it does still say "command failed" in the exception but dosent provide the information it normally provides if you set it to pipe (well in case the pipe option actually works as expected(like if you dont change stdio in the first place which is what the issue is for))
e.g.
the exception without any stdio options:

Error: Command failed: net session
System error 5 has occurred.       

Access is denied.

with ignore:

Error: Command failed: net session

PS this is my first issue so please forgive me for any issues

@avivkeller
Copy link
Member

avivkeller commented Aug 29, 2024

Have you tried adding shell: true to the options?

Also, can you reproduce in the latest version of the release line?

@avivkeller avivkeller added child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform. labels Aug 29, 2024
@OrdinaryDude2634
Copy link
Author

i tried shell: true and i still get the same results. even if that somehow fixed the issue it should be documented or changed so it's more clear (incase shell: true actually fixed it)
also tested on 22.7.0 and still the same behavior

@avivkeller
Copy link
Member

CC @nodejs/platform-windows @nodejs/child_process

jazelly added a commit to jazelly/node that referenced this issue Sep 9, 2024
jazelly added a commit to jazelly/node that referenced this issue Sep 9, 2024
Fixes: nodejs#54649
Refs: nodejs#54293

Co-authored-by: Zanette Arrigo <arrigo.zanette@m31.com>
@huseyinacacak-janea
Copy link
Contributor

I tried to reproduce it locally, but saw at least one log in the terminal. It also throws an exception which you can catch and print the error message in the parent process in both cases. Do you think this should be investigated further? If so, could you provide a full example of your code that generates an error?

> cp.execSync('net session');
System error 5 has occurred.

Access is denied.

Uncaught Error: Command failed: net session
System error 5 has occurred.

Access is denied.


    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at Object.execSync (node:child_process:963:15) 
...
> cp.execSync('net session', {stdio:'pipe'});
Uncaught Error: Command failed: net session
System error 5 has occurred.

Access is denied.


    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at Object.execSync (node:child_process:963:15) 
...

@StefanStojanovic
Copy link
Contributor

Since the last comment was unanswered for 2 months, I'll close this issue. Feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

4 participants