Closed
Description
Is your feature request related to a problem? Please describe.
I want to use the inspector module in a worker thread to control the inspector in another thread.
const { isMainThread, Worker } = require('worker_threads');
const inspector = require('inspector');
if (isMainThread) {
new Worker(__filename)
} else {
// session connects to the worker thread inspector, not the main thread.
const session = new inspector.Session();
session.connect();
}
inspector.Session
doesn't support connecting to the inspector of a different thread or process.
Describe the solution you'd like
- add a
url
parameter toinspector.Session
if (isMainThread) {
inspector.open(0);
const url = inspector.url();
new Worker(__filename, { workerData: { url }})
} else {
const session = new inspector.Session(workerData.url);
// ...
}
- or allow
inspector
to be transfered
if (isMainThread) {
new Worker(__filename, { workerData: { inspector }})
} else {
const session = new new workerData.inspector.Session();
// ...
}
Describe alternatives you've considered
The v8 inspector API is not complicated and I have written a client using the ws
npm module instead of using inspector.Session
.
I'm open to writing a CR to implement this, but I would like feedback from a maintainer before I start, especially because both worker_threads
and inspector
are experimental.
Metadata
Metadata
Assignees
Labels
No labels