Skip to content

Commit 76622c4

Browse files
MoLowjuanarbol
authored andcommitted
inspector: allow opening inspector when NODE_V8_COVERAGE is set
PR-URL: #46113 Fixes: #46110 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f2bba1b commit 76622c4

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/inspector_js_api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo<Value>& args) {
272272

273273
void IsEnabled(const FunctionCallbackInfo<Value>& args) {
274274
Environment* env = Environment::GetCurrent(args);
275-
args.GetReturnValue().Set(InspectorEnabled(env));
275+
args.GetReturnValue().Set(env->inspector_agent()->IsListening());
276276
}
277277

278278
void Open(const FunctionCallbackInfo<Value>& args) {

test/fixtures/inspector-open.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const assert = require('assert');
2+
const inspector = require('inspector');
3+
4+
5+
assert.strictEqual(inspector.url(), undefined);
6+
inspector.open(0, undefined, false);
7+
assert(inspector.url().startsWith('ws://'));
8+
assert.throws(() => {
9+
inspector.open(0, undefined, false);
10+
}, {
11+
code: 'ERR_INSPECTOR_ALREADY_ACTIVATED'
12+
});
13+
inspector.close();
14+
assert.strictEqual(inspector.url(), undefined);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const { spawnSync } = require('child_process');
6+
const fixtures = require('../common/fixtures');
7+
const tmpdir = require('../common/tmpdir');
8+
9+
common.skipIfInspectorDisabled();
10+
common.skipIfWorker();
11+
12+
tmpdir.refresh();
13+
14+
15+
let output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')]);
16+
assert.strictEqual(output.status, 0);
17+
18+
output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')], {
19+
env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path },
20+
});
21+
assert.strictEqual(output.status, 0);

0 commit comments

Comments
 (0)