Skip to content

Commit 44f774c

Browse files
committed
inspector: allow opening inspector when NODE_V8_COVERAGE is set
1 parent cd4f4b4 commit 44f774c

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

lib/inspector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class Session extends EventEmitter {
168168
* @returns {void}
169169
*/
170170
function inspectorOpen(port, host, wait) {
171-
if (isEnabled()) {
171+
if (isEnabled() && url()) {
172172
throw new ERR_INSPECTOR_ALREADY_ACTIVATED();
173173
}
174174
// inspectorOpen() currently does not typecheck its arguments and adding

test/fixtures/inspector-open.js

Lines changed: 14 additions & 0 deletions
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);
Lines changed: 21 additions & 0 deletions
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)