Skip to content

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

Description

@ThisIsMissEm

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

Activity

  1. addaleax commented on Aug 21, 2019

    @addaleax
    Member

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

  2. added
    feature requestIssues requesting new Node.js features.
    inspectorIssues and PRs related to the V8 inspector protocol.
    on Aug 21, 2019
  3. ThisIsMissEm commented on Aug 21, 2019

    @ThisIsMissEm
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.inspectorIssues and PRs related to the V8 inspector protocol.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions