bol].dispatch(JSONStringify(message)); } /** * Immediately closes the session, all pending * message callbacks will be called with an * error. * @returns {void} */ disconnect() { if (!this[connectionSymbol]) return; this[connectionSymbol].disconnect(); this[connectionSymbol] = null; const remainingCallbacks = this[messageCallbacksSymbol].values(); for (const callback of remainingCallbacks) { process.nextTick(callback, new ERR_INSPECTOR_CLOSED()); } this[messageCallbacksSymbol].clear(); this[nextIdSymbol] = 1; } } /** * Activates inspector on host and port. * @param {number} [port] * @param {string} [host] * @param {boolean} [wait] * @returns {void} */ function inspectorOpen(port, host, wait) { if (isEnabled()) { throw new ERR_INSPECTOR_ALREADY_ACTIVATED(); } open(port, host); if (wait) waitForDebugger(); } /** * Blocks until a client (existing or connected later) * has sent the `Runtime.runIfWaitingForDebugger` * command. * @returns {void} */ function inspectorWaitForDebugger() { if (!waitForDebugger()) throw new ERR_INSPECTOR_NOT_ACTIVE(); } module.exports = { open: inspectorOpen, close: process._debugEnd, url, waitForDebugger: inspectorWaitForDebugger, // This is dynamically added during bootstrap, // where the console from the VM is still available console: require('internal/util/inspector').consoleFromVM, Session };