-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: return void in InitializeInspector()
We have been ignoring inspector port binding errors during startup. Handling this error would be a breaking change and it's probably surprising to refuse to launch the Node.js instance simply because the inspector cannot listen to the port anyway. So just turn the return value of InitializeInspector() and remove the TODOs for handling the error. PR-URL: #44903 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
b2e6048
commit 824dcfc
Showing
6 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const { spawnSync } = require('child_process'); | ||
const { createServer } = require('http'); | ||
const assert = require('assert'); | ||
const fixtures = require('../common/fixtures'); | ||
const entry = fixtures.path('empty.js'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
function testOnServerListen(fn) { | ||
const server = createServer((socket) => { | ||
socket.end('echo'); | ||
}); | ||
|
||
server.on('listening', () => { | ||
fn(server); | ||
server.close(); | ||
}); | ||
server.listen(0, '127.0.0.1'); | ||
} | ||
|
||
function testChildProcess(getArgs, exitCode) { | ||
testOnServerListen((server) => { | ||
const { port } = server.address(); | ||
const child = spawnSync(process.execPath, getArgs(port)); | ||
const stderr = child.stderr.toString().trim(); | ||
const stdout = child.stdout.toString().trim(); | ||
console.log('[STDERR]'); | ||
console.log(stderr); | ||
console.log('[STDOUT]'); | ||
console.log(stdout); | ||
const match = stderr.match( | ||
/Starting inspector on 127\.0\.0\.1:(\d+) failed: address already in use/ | ||
); | ||
assert.notStrictEqual(match, null); | ||
assert.strictEqual(match[1], port + ''); | ||
assert.strictEqual(child.status, exitCode); | ||
}); | ||
} | ||
|
||
testChildProcess( | ||
(port) => [`--inspect=${port}`, '--build-snapshot', entry], 0); | ||
testChildProcess( | ||
(port) => [`--inspect=${port}`, entry], 0); | ||
|
||
testOnServerListen((server) => { | ||
const { port } = server.address(); | ||
const worker = new Worker(entry, { | ||
execArgv: [`--inspect=${port}`] | ||
}); | ||
|
||
worker.on('error', common.mustNotCall()); | ||
|
||
worker.on('exit', common.mustCall((code) => { | ||
assert.strictEqual(code, 0); | ||
})); | ||
}); |