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 to inspector.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.
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.
inspector.Sessiondoesn't support connecting to the inspector of a different thread or process.Describe the solution you'd like
urlparameter toinspector.Sessioninspectorto be transferedDescribe alternatives you've considered
The v8 inspector API is not complicated and I have written a client using the
wsnpm module instead of usinginspector.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_threadsandinspectorare experimental.