Skip to content

is there some way to debug a process ignoring child processes that tries to connect to the debugger? #649

Closed

Description

@bjrmatos
  • Node.js Version: 8.0.0
  • OS: OSX
  • Scope (install, code, runtime, meta, other?): code, runtime

i'm trying to debug my node.js application (using --inspect), the application uses some third-party modules that make use of the child_process module internally.

when i try to debug my app and when some part of the code reach other part that uses child_process a message like this is printed Starting inspector on 0.0.0.0:9229 failed: address already in use and the child process exits with an exit code of 12 (which is documented in docs), what i understand is that all nodejs child processes by default tries to connect to the inspector on the same port (9229 by default), however i'm trying to find a way to tell node that all child processes should not try to connect to the inspector, i'm only interested in debugging all the code that is running in the same process, this is something that was possible using the now deprecated node-inspector package, with node-inspector all code can work normally because child processes does not try to connect to the debugging session, which makes debugging all the code in the main process possible.

is there something i can do to achieve this? it is really annoying that the application does not work correctly in debugging mode for this reason. thanks!

Activity

  1. changed the title [-]is there some way to debug a process ignoring child processes that tries to connect the debugger?[/-] [+]is there some way to debug a process ignoring child processes that tries to connect to the debugger?[/+] on May 31, 2017
  2. bnoordhuis commented on May 31, 2017

    @bnoordhuis
    Member

    Node.js v8.1.0 will let each process bind to a separate random port with --inspect=0. Would that help?

  3. bjrmatos commented on May 31, 2017

    @bjrmatos
    Author

    thnks for answering! and yes i think that at least it will let the application to run normally without exits of child processes.

    just one concern, in the theorical case that some package that uses a child process gets published with a debugger; statement inside of it, does it will block the execution if i don't have for example a chrome debug session opened (the inspector opened in a chrome tab)?

  4. bnoordhuis commented on May 31, 2017

    @bnoordhuis
    Member

    No, debugger is a no-op unless there is a debug client attached (e.g DevTools or VS Code) attached.

    In fact, if you wanted the option to break at an early debugger statement, you'd start node with --inspect-brk=<port> to give the debug client time to attach.

  5. bjrmatos commented on May 31, 2017

    @bjrmatos
    Author

    clear now, looking forward for random ports thnk you!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions