-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible support for child processes #5
Comments
So, this is a node.js problem. I'm guessing that we're not the first to require debugging of child processes. If node provides a debugging feature and it provides a child process feature, it should extend the debugging feature to the child process feature. Is how I see it. In another thought, if we run node with |
Is this going to help with the portfinder issue? |
I've requested a feature that may solve this issue upstream in Node.js: |
Thanks for info/followup @mightyiam. I am following the relevant discussions and will try to address ASAP. |
May be a good place to start: https://github.com/tapjs/spawn-wrap |
Oh, the things we do... |
@mightyiam |
Yes, spawn-wrap is designed for this exact purpose, and works surprisingly well, apart from a few caveats. (I say "surprisingly", because it's so hacky that it's practically a miracle it works at all.) Most notably, using two spawn wraps at once is not possible at this time. |
@jaridmargolin I'm not familiar enough with the project to know whether this tip will be helpful, but I've had success propagating the child_process.fork(path, args, {
env: process.env,
cwd: process.cwd(),
execArgv: ['--inspect']
}) |
Last unknown is how to best integrate with devtools at an interface level. Will I need to open a new tab/window for every child_process, or is there a way for a single devtools session to listen on multiple ports? I know it is possible to debug nodejs in parallel with browser js. @paulirish - Any chance you could provide insight into current capabilities? I'd like to set some time aside over the next week or so to attack this issue. |
Yes definitely. :) . @pavelfeldman and I just walked through this flow and it looks reasonable. You can see it normally with web workers: and yeah its a very similar thing to do the parallel debug. You'll have to MITM the protocol traffic. Looks like you're not doing that now, but in order to convince devtools it has multiple targets to debug simultaneously, you'll have to talk the talk. So DevTools will connect over 9222 (or whatever) to The target domain is what enables devtools to connect to all this stuff: https://chromedevtools.github.io/debugger-protocol-viewer/tot/Target/
Doing that should get you this sweet UI and everything else just comes totally free. I probably left out details around how you announce the death of child_processes, etc.. but it's something else here in the Target domain. really happy ya'll are taking this on. excited. :) |
@paulirish - Thank you! My current communication with devtools is an incredibly naive approach that utilizes selenium to drive the UI (at best its a brittle hack). I'm going to have to do a deep dive into the information you sent over, but I'm encouraged by possibilities. |
Shoulnd't 👿-lementation of child process debugging be in node? |
@mightyiam perhaps. At this point, this sort of work would almost be easier to do in node-core as then inspect-process wouldn't have to get into the business of becoming a websocket MITM proxy for the protocol. It might be a tad easier to prototype the work over here and then once its proven, upstream it to node-core. shrug @jaridmargolin i just looked and you're just using selenium to manage the devtools window. all that stuff could stay the same.. it's just that the debuggerUrl that gets opened, would be adjusted to be opening your new websocket endpoint rather than node's. |
A quick note, following on from #37 (comment) I have the following npm script:
This allows me to:
If the resolution to this issue allows the above script to be wrapped by inspect-process, then can I suggest it's added to the docs as an example? |
I am unable to connect with chrome to debug my node app, that is running in mine docker. This is my command:
And this is my docker-compose.yml
This is the log:
I configure What am I doing wrong? |
|
|
It may be possible to monkey patch child_process methods to force inspect. I would almost always consider this bad practice, but perhaps it could live behind a flag --patch or --inspect-children?
The underlying question being if the ease of use this is worth the potential unknown edge cases it may create.
Known Complexities
Finding an available port would not be possible with our current implementation.
spawn
is expected to immediately return the process but portfinder resolves asynchronously.Altering the std spy/filter to manage the lifecycle of these spawned child processes may be difficult. I'm fairly certain it can done, but there is definitely a question of how hacky/reliable the solution would be.
The text was updated successfully, but these errors were encountered: