-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix Worker termination when '--inspect-brk' is passed
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: #53724 Fixes: #53648 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
- Loading branch information
1 parent
4647e6b
commit ef5dabd
Showing
9 changed files
with
114 additions
and
20 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
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
47 changes: 47 additions & 0 deletions
47
test/parallel/test-inspector-exit-worker-in-wait-for-connection2.js
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,47 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const { workerData, Worker } = require('node:worker_threads'); | ||
if (!workerData) { | ||
common.skipIfWorker(); | ||
} | ||
|
||
const assert = require('node:assert'); | ||
|
||
let TIMEOUT = common.platformTimeout(5000); | ||
if (common.isWindows) { | ||
// Refs: https://github.com/nodejs/build/issues/3014 | ||
TIMEOUT = common.platformTimeout(15000); | ||
} | ||
|
||
// Refs: https://github.com/nodejs/node/issues/53648 | ||
|
||
(async () => { | ||
if (!workerData) { | ||
// worker.terminate() should terminate the worker created with execArgv: | ||
// ["--inspect-brk"]. | ||
{ | ||
const worker = new Worker(__filename, { | ||
execArgv: ['--inspect-brk=0'], | ||
workerData: {}, | ||
}); | ||
await new Promise((r) => setTimeout(r, TIMEOUT)); | ||
worker.on('exit', common.mustCall()); | ||
await worker.terminate(); | ||
} | ||
// process.exit() should kill the process. | ||
{ | ||
new Worker(__filename, { | ||
execArgv: ['--inspect-brk=0'], | ||
workerData: {}, | ||
}); | ||
await new Promise((r) => setTimeout(r, TIMEOUT)); | ||
process.on('exit', (status) => assert.strictEqual(status, 0)); | ||
setImmediate(() => process.exit()); | ||
} | ||
} else { | ||
console.log('Worker running!'); | ||
} | ||
})().then(common.mustCall()); |