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

Listening to SIGUSR1 blocks debugger #19619

Closed
mlucool opened this issue Mar 26, 2018 · 4 comments
Closed

Listening to SIGUSR1 blocks debugger #19619

mlucool opened this issue Mar 26, 2018 · 4 comments
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. inspector Issues and PRs related to the V8 inspector protocol

Comments

@mlucool
Copy link

mlucool commented Mar 26, 2018

  • Version: v8.9.4
  • Platform: 3.10.0-693.17.1.el7.x86_64

I am not sure which is the correct behavior for an intercepted SIGUSR1, the documentation or the a test case. Can the code and/or documentation please be fixed?

process documentation says:

SIGUSR1 is reserved by Node.js to start the debugger. It's possible to install a listener but doing so will not stop the debugger from starting.

But a quick test shows that the debugger is not started.

Code:

let i = 0;
setInterval(() =>
        console.log(i++),
    1000);

process.on('SIGUSR1', () => console.log('Got SIGUSR1'))

If you send a SIGUSR1 only Got SIGUSR1 is printed. The typical Debugger listening on ws://127.0.0.1:9229/66fb119d-2443-4bdf-80b1-6386995ba253 is not printed. You can also verify that the debugger didn't start with with netstat -ap.

@targos
Copy link
Member

targos commented Mar 26, 2018

@nodejs/v8-inspector

@targos targos added the inspector Issues and PRs related to the V8 inspector protocol label Mar 26, 2018
@bnoordhuis
Copy link
Member

It depends on when the inspector is started. If it's activated at startup, then the JS code will override it. If it's activated later, it subsumes the JS listener.

I think right now it's always started early (require('inspector').open() uses a different mechanism) but it hasn't always been that way and it could change again in the future.

I'd use guarded language: "It's possible to install a listener but doing so might interfere with the debugger."

@bnoordhuis bnoordhuis added doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. labels Mar 27, 2018
@willhayslett
Copy link
Contributor

@bnoordhuis please let me know if the changes are okay or if additional edits are needed. Thanks.

willhayslett added a commit to willhayslett/node that referenced this issue Mar 31, 2018
Updated the doc/api/process.md documentation to reflect that
listening on SIGUSR1 could impact the debugger.

Fixes: nodejs#19619
@mlucool
Copy link
Author

mlucool commented Apr 2, 2018

@bnoordhuis Do you expect this to always work/enable me to set the port at runtime?

process.on('SIGUSR1', () => {
    const port = myPortFinder();
    require('inspector').open(port);
});

@trivikr trivikr closed this as completed in 67bbc84 Apr 3, 2018
targos pushed a commit that referenced this issue Apr 3, 2018
Updated the doc/api/process.md documentation to reflect that
listening on SIGUSR1 could impact the debugger.

Fixes: #19619

PR-URL: #19709
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this issue Dec 4, 2018
Updated the doc/api/process.md documentation to reflect that
listening on SIGUSR1 could impact the debugger.

Fixes: #19619

PR-URL: #19709
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants