-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: node.js debugger adds stderr (but exit code is 0) -> shouldn't throw #2719
Conversation
gyp/pylib/gyp/input.py
Outdated
if p.wait() != 0: | ||
sys.stderr.write(p_stderr) | ||
# Simulate check_call behavior, since check_call only exists | ||
# in python 2.5 and later. |
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.
if p.wait() != 0: | |
sys.stderr.write(p_stderr) | |
# Simulate check_call behavior, since check_call only exists | |
# in python 2.5 and later. | |
if p_stderr: | |
sys.stderr.write(p_stderr) | |
if p.wait() != 0: |
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.
Is there a simple way that this code can detect the presence of the debugger?
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.
If we are going to make changes here, the recommended path is to upgrade to subprocess.run()
to remove a lot of clutter.
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.
keep comments ? (I think it's for the raise
below) (keep/delete) ?
# Simulate check_call behavior, since check_call only exists
# in python 2.5 and later.
raise GypError(
"Call to '%s' returned exit status %d while in %s."
% (contents, p.returncode, build_file)
)
this is better behavior, no loss of stderr output (possible useful debug log)
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.
We do not need the comment about Py25... subprocess.check_cal()
is fully available to us on all supported versions of Python and the even simpler subprocess.run()
is too.
Will all users have the debugger present? If not, what is the effect of the proposed changes on those users?
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.
what is the effect of the proposed changes on those users?
<!(node -p \"require('node-addon-api').gyp\")
oof, the scope is Any command..
Is there a simple way that this code can detect the presence of the debugger?
there may be another way: silence the:
Debugger attached.
Waiting for the debugger to disconnect...
https://github.com/nodejs/node/blob/fddc701d3c0eb4520f2af570876cc987ae6b4ba2/src/inspector_agent.cc#L802-L805
It seems that it only prints if no parent
python spawning seems like a parent ? I'll have to check more
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.
Stderr doesn’t mean error,
Status code > 0 means error
Yes, programs can output to standard error and still return a zero exit status. You will find many POSIX utilities specifications which state that "The standard error shall be used only for diagnostic messages."
https://unix.stackexchange.com/a/594670
this is the correct handling
If any program wants to indicate error, just set status code
975e98a
to
93df27b
Compare
gyp/pylib/gyp/input.py
Outdated
# Simulate check_call behavior, since check_call only exists | ||
# in python 2.5 and later. |
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.
# Simulate check_call behavior, since check_call only exists | |
# in python 2.5 and later. |
Remove.
the tests aren't even re-ran after force-push, this broke 2 tests |
it's checking if the last line of stderr === 'gyp info ok' |
nevermind, no breaking changes, |
I feel that checking the last line of something isn't a foolproof way of checking for success, maybe exit code ? I'll have to check the intention |
) | ||
replacement = p_stdout.rstrip() | ||
replacement = result.stdout.decode("utf-8").rstrip() |
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.
Add text = True
to the run()
call and then...
replacement = result.stdout.decode("utf-8").rstrip() | |
replacement = result.stdout.rstrip() |
cwd=build_file_dir, | ||
check=False |
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.
check=False | |
check=False, | |
text=True |
fails python 3.6 tests
|
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.
LGTM (Once all tests are passing ;-) )
002afb4
to
c3e909d
Compare
Yes. Py36 is end-of-life https://devguide.python.org/versions so we should drop support for it but let's move this forward as is. |
this shouldn't have been merged here but over in gyp-next: https://github.com/nodejs/gyp-next/blob/main/pylib/gyp/input.py I believe it's going to get overwritten with a upgrade. @FuPeiJiang would you mind doing an equivalent PR over there please? |
Debugger attached.
Waiting for the debugger to disconnect...
Checklist
npm install && npm test
passesDescription of change