Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reuse/restart the same node inspect session

Once a node.js program has run to completion in the context of an --inspect session (i.e. via the Chrome dev tools debugger) is it possible to re-start it without having to re-issue the --inspect command from the command-line?

The issue with re-issuing an --inspect command is that it generates a different chrome url every time and one has to then copy-paste this into Chrome each time. Ideally I want to be able to push F5 to re-start the chrome debug session.

So two issues:

  1. I cannot restart the debug session without killing the current (i.e. no way to just refresh).
  2. I have to copy paste the url into chrome each time I start a new session. (not as bad as issue 1.)
like image 780
Steven Mark Ford Avatar asked Feb 20 '17 09:02

Steven Mark Ford


1 Answers

Here's a couple of options for you, though neither will provide you with a simple F5 refresh, both are significantly better than copy/pasting the new URL generated by the --inspect flag.

The most optimal solution is installing this extension for Chrome or Opera: https://chrome.google.com/webstore/detail/nim-node-inspector-manage/gnhhdgbaldcilmgcpfddgdbkhjohddkj

NIM (Node Inspector Manager)

This will manage the node inspector for you. Just click the resulting toolbar icon and select "Auto" from the toggle switch. Your browser will then open the Chrome DevTools in inspection mode whenever your node server generates an inspection URL.

If you want to go the low-tech (and more manual) route, or don't want to install a Chrome extension, just open your Chrome to "chrome://inspect", wait a moment, and you'll get a list under Remote Target that will include your Node server. Just click the "inspect" link there, and the DevTools will open with the current URL. The downside of this method is you'll need to reclick that "inspect" link every time your server restarts. It avoids copy/pasting URLs, but still involves manual labor.

chrome:inspect method

like image 149
Artif3x Avatar answered Nov 02 '22 02:11

Artif3x