-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
inspector: support for worker inspection in chrome devtools #56759
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
})); | ||
} | ||
|
||
test().then(common.mustCall()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test()
function wrapper is no longer needed: by default, an unhandled promise rejection makes the process exit with a non-zero exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
I removed the wrapper.
Tracing the history discussion, it would be great to have @eugeneo, @pavelfeldman and @dgozman weighing in this work |
Confirmed with Chrome DevTools team (dsv@, caseq@) that they are good with Node.js implementing the Target domain for worker discovery, or implementing NodeWorker domain support in Chrome DevTools frontend. As the Target domain in this PR is behind the flag |
Thank you! |
141ec5a
to
984f640
Compare
984f640
to
fafadd0
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56759 +/- ##
==========================================
- Coverage 89.21% 89.16% -0.05%
==========================================
Files 663 667 +4
Lines 192001 193305 +1304
Branches 36923 37204 +281
==========================================
+ Hits 171290 172358 +1068
- Misses 13582 13697 +115
- Partials 7129 7250 +121
|
Issue to devtools-frontend |
const sessionId = '1'; | ||
await session.waitForNotification('Target.targetCreated'); | ||
await session.waitForNotification((notification) => { | ||
return notification.method === 'Target.attachedToTarget' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event Target.attachedToTarget
should not be emitted without a Target.setAutoAttach
command or Target.attachToTarget
command.
// TODO(islandryu): Currently, setAutoAttach applies the main thread's value to | ||
// all threads. Modify it to be managed per worker thread. | ||
crdtp::DispatchResponse TargetAgent::setAutoAttach( | ||
bool auto_attach, bool wait_for_debugger_on_start) { | ||
auto_attach_ = auto_attach; | ||
wait_for_debugger_on_start_ = wait_for_debugger_on_start; | ||
|
||
if (auto_attach) { | ||
for (auto& target : targets_) { | ||
if (!target.attached) { | ||
target.attached = true; | ||
attachedToTarget(target.worker, | ||
target.target_id, | ||
target.type, | ||
target.title, | ||
target.url); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setAutoAttach is implemented.
However, I am not able to determine autoAttach for each related Target and waitForDebuggerOnStart.
I have tried several way, but it was difficult to make the changes without affecting the existing nodeWorker, so I would like to make a TODO.
This PR introduces support for inspecting workers in Chrome DevTools. I would like to gather some feedback to confirm whether there seem to be no issues with this approach. If the approach in this PR deviates significantly from the desired direction, I am happy to close it. However, if the general approach seems acceptable, I will proceed with this PR and submit a change request to Chrome DevTools.
Summary of Changes
This implementation uses the
attachedToTarget
event to notify the creation of workers. More details on the protocol can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/Target/#event-attachedToTarget).This sequence is how to worker inspection works.
When a worker is created, attachedToTarget is notified to the server, and the server thread allocates methods from the client to the appropriate thread based on the sessionId.
How to Verify
Currently, dedicated DevTools for Node.js do not support worker targets. For verification, use
inspector.html
:Steps:
index.js
andworker.js
files for testing:index.js
:worker.js
:Currently, the results of console.log within the worker are being sent twice, but I'm working on fixing this issue.Additional Information
The approach used in this PR follows the CDP (Chrome DevTools Protocol) and is different from the Node.js worker debugging protocol used in VSCode. It adheres to the existing CDP protocol to ensure compatibility.
fix #56343