Based on #7992, I'm filing this issue to start a discussion around supporting a flag that would open or refresh an inspect
session. Because copying/pasting the URL is a suboptimal workflow. I believe there's a chrome extension that will basically do this, but it'd be really nice to have it supported natively.
Probably related: https://github.com/nodejs/node/pull/11207 (If we decide to be vendor-neutral about the --inspect
behavior...)
Just a thought, but perhaps this would be better suitable as a feature addition to node-inspect
? That is, provide the ability to launch node-inspect
with an option that opens a third-party debug client like Chrome as opposed to launching the command line debugger client.
example:
$ NODE_INSPECTOR=chrome node-inspect foo.js
I don't think this is a good idea for core. We'd have to know how to start every set of supported debugging tools on every supported platform. It also wouldn't be very vendor neutral.
I tend to agree with @cjihrig and @jasnell. I would worry that this would bloat node unnecessarily. I would however like a blessed and official solution for this problem. Does such a solution exist?
I should say as a side note that the debugging story for node is definitely an area that needs work. Most people are still using console.log
just because that's the path of least resistance. It's further complicated by the number of people using babel or TypeScript. If we could make the debugging story more straightforward, I think that would make things so much better for everyone.
Going with an environment variable approach where the value of the env var is required to include the launch pattern for the debugger would certainly provide a workable generic approach. e.g. NODE_INSPECTOR="chrome %u"
where %u
is replaced by the debugger URL on launch. It would be something that could be easily baked in to node-inspect
without incurring the additional bloat of trying to teach it how to launch multiple tools
/cc @jkrems
Because copying/pasting the URL is a suboptimal workflow.
I totally agree - it's not a good workflow. I wish we wouldn't be printing those URLs. If you're using Chrome Devtools, you can just go to chrome://inspect
, click "Open dedicated DevTools for Node", and it will do all the connecting & reconnecting for you. :) Unless you use highly dynamic ports & IPs, you shouldn't have to copy & paste the URL.
I say highly dynamic because as long as you have a limited set of IP+port combinations, you can use "Configure..." to register them on chrome://inspect
. And from then on we're back to "no copy&paste required".
Thanks @jkrems. That's the best way to do things now. We can close this. For what it's worth, that workflow didn't exist when I filed this issue. Glad the workflow is much better now :)
@kentcdodds Sorry, didn't mean to imply that the ticket wasn't totally reasonable at the time. :)
Use Node.js V8 --inspector Manager (NiM) Chrome plugin, it opens Chrome automagically when I run node --inspect-brk app
Most helpful comment
Going with an environment variable approach where the value of the env var is required to include the launch pattern for the debugger would certainly provide a workable generic approach. e.g.
NODE_INSPECTOR="chrome %u"
where%u
is replaced by the debugger URL on launch. It would be something that could be easily baked in tonode-inspect
without incurring the additional bloat of trying to teach it how to launch multiple tools