-
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,test: add regression test for nested Worker termination
This adds a regression test for terminating a Worker inside which another Worker is running. PR-URL: #32623 Refs: #32531 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
// Check that a Worker that's running another Worker can be terminated. | ||
|
||
const worker = new Worker(` | ||
const { Worker, parentPort } = require('worker_threads'); | ||
const worker = new Worker('setInterval(() => {}, 10);', { eval: true }); | ||
worker.on('online', () => { | ||
parentPort.postMessage({}); | ||
}); | ||
`, { eval: true }); | ||
|
||
worker.on('message', common.mustCall(() => worker.terminate())); |