summaryrefslogtreecommitdiff
path: root/lib/inspector.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/inspector.js')
-rw-r--r--lib/inspector.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/inspector.js b/lib/inspector.js
index 4bec628b7d..198d87ae44 100644
--- a/lib/inspector.js
+++ b/lib/inspector.js
@@ -8,6 +8,7 @@ const {
ERR_INSPECTOR_COMMAND,
ERR_INSPECTOR_NOT_AVAILABLE,
ERR_INSPECTOR_NOT_CONNECTED,
+ ERR_INSPECTOR_NOT_ACTIVE,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_CALLBACK
} = require('internal/errors').codes;
@@ -19,7 +20,12 @@ if (!hasInspector)
const EventEmitter = require('events');
const { validateString } = require('internal/validators');
const util = require('util');
-const { Connection, open, url } = internalBinding('inspector');
+const {
+ Connection,
+ open,
+ url,
+ waitForDebugger
+} = internalBinding('inspector');
const connectionSymbol = Symbol('connectionProperty');
const messageCallbacksSymbol = Symbol('messageCallbacks');
@@ -105,10 +111,22 @@ class Session extends EventEmitter {
}
}
+function inspectorOpen(port, host, wait) {
+ open(port, host);
+ if (wait)
+ waitForDebugger();
+}
+
+function inspectorWaitForDebugger() {
+ if (!waitForDebugger())
+ throw new ERR_INSPECTOR_NOT_ACTIVE();
+}
+
module.exports = {
- open: (port, host, wait) => open(port, host, !!wait),
+ open: inspectorOpen,
close: process._debugEnd,
url: url,
+ waitForDebugger: inspectorWaitForDebugger,
// This is dynamically added during bootstrap,
// where the console from the VM is still available
console: require('internal/util/inspector').consoleFromVM,