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

Ability to trigger --inspect --inspect-brk from code #29250

Closed
ThisIsMissEm opened this issue Aug 21, 2019 · 2 comments
Closed

Ability to trigger --inspect --inspect-brk from code #29250

ThisIsMissEm opened this issue Aug 21, 2019 · 2 comments
Labels
feature request Issues that request new features to be added to Node.js. inspector Issues and PRs related to the V8 inspector protocol

Comments

@ThisIsMissEm
Copy link

Is your feature request related to a problem? Please describe.
Yes, I've a node.js CLI app which I'd like to enable debugging off via setting DEBUG=my-cli before running my program; As it uses #! and other things, I can't set the flags to the node executable.

I have discovered I can start the inspector programmatically, but not in --inspect-brk mode, so my program runs and exits before I can connect to the inspector.

if (process.env.DEBUG && process.env.DEBUG.includes("my-cli")) {
  process.kill(process.pid, "SIGUSR1");
}

Describe the solution you'd like

Ideally, it'd be great to have some sort of API like: Inspector.start() or Inspector.start({ break: true }) to start the inspector and also make it break-point immediately, even though no clients are yet connected to the inspector.

Describe alternatives you've considered

There's not really other alternatives, other than doing:

node --inspect --inspect-brk ./bin/run ...

I don't think I can do:

node --inspect --inspect-brk my-cli

Which isn't ideal, as it's leaking internals of how my package works to consumers, whereas DEBUG=my-cli my-cli doesn't

@addaleax
Copy link
Member

Does #28453 (released in v12.7.0) give you what you want? There’s a short usage example in the PR description.

@addaleax addaleax added feature request Issues that request new features to be added to Node.js. inspector Issues and PRs related to the V8 inspector protocol labels Aug 21, 2019
@ThisIsMissEm
Copy link
Author

Yes! That looks like it'll solve my use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

No branches or pull requests

2 participants