How to get the debugging target information for a node.js process in a Google Chrome extension?

252 views
Skip to first unread message

Jacob Beard

unread,
Sep 7, 2017, 1:45:12 AM9/7/17
to Google Chrome Developer Tools

Hi,


I would like to write a Chrome extension that uses the chrome.debugger API to attach to a node.js process started with "--inspect", in order to set breakpoints and control execution of the node process. I consulted the documentation, and it appears I would use the API chrome.debugger.attach in order to attach the debugging client to the node.js process. The attach API accepts as an argument the targetId of the debugging target to attach. My question is, how can I find the targetId of the Node.js process, which I can pass to attach?


I attempted to find the node.js debugging target using the chrome.debugger.getTargets API, but the resulting array of targetInfo did not include the node.js process. The node.js process does appear in chrome://inspect, and I am able to use chrome devtools to inspect the process. I'm wondering if the node.js process does not appear in the targetInfo results because the node.js process is a remote debugging target, whereas all other results in this array were local debugging targets.


I would appreciate any insight into this. Thank you for your help,


Jake

Jacob Beard

unread,
Sep 7, 2017, 12:07:33 PM9/7/17
to Google Chrome Developer Tools
Hi,

Upon further investigation, I found that:
  • chrome.debugger.onEvent does not fire debugger events attached to the node.js process target; but the events fire when the debugger is attached to tabs.
  • chrome.debugger.getTargets doesn't return node.js target in targetInfos
  • Fetching the debug target info from the remote JSON API endpoint /json/list, and passing the targetId to chrome.debugger.attach fails to find the debug target.
Based upon this evidence, it seems like chrome.debugger may not currently support remote targets, like the remote node.js process. I was wonder if someone could confirm this hypothesis?

I also found the following chrome issue which might be related:


Thank you,

Jake
Reply all
Reply to author
Forward
0 new messages