Why is the Inspector Disabled in Node.js Mode?¶
Javet does not support Node.js
--inspect because Node.js is designed to be singleton.
It is fine to create and close the NodeRuntime one by one (I have tested). But if applications create multiple NodeRuntime instances at the same time, Javet will crash immediately. Why?
Node.js has only one IO thread serving the inspector agent. In side the function
CHECK_EQ(start_io_thread_async_initialized.exchange(true), false); makes sure that
static std::atomic_bool start_io_thread_async_initialized; is flipped from
true, then crashes if
Agent::Start(...) is called again. Creating a NodeRuntime instance triggers that call and there is no workaround. The crash is inevitable.
The hacky option is to change the Node.js source code. But that scope would be too large because that implies changing the fundamental design of the inspector. I don't think the Node.js community would accept that.