Search code examples
node.jsdebuggingsignals

How to close NodeJS debugger remotely?


Given NodeJS process is running in in production and I have an endpoint which signals to process.

  @Get('/signal/:signal')
  async makeSignal(@Param('signal') signal: string) {
    process.kill(process.pid, signal);
  }

According to docs, I was able to send SIGUSR1 signal to start listenning for debugger.

Is it possible to disconnect attached debuggers and stop listening for next debuggers so noone can connect?

In other words, how to undo it? Is there any other signal?


Solution

  • According to reply from NodeJS community Ability to stop debugger listening #42446 the only way to close debugger remotely - to use inspector module.

    The SIGUSR1 signal is usefull for attaching debugger in cases where using inspector is not possible (e.g. forever loops)