-
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.
worker: remove redundant function call to
setupPortReferencing
in `setupChild` There is no need to call `setupPortReferencing` in `setupChild` as which has been called with the same arguments in the `oninit` prototype method of `MessagePort`.
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
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,25 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
const assert = require('assert'); | ||
const common = require('../common'); | ||
const { isMainThread, parentPort, Worker } = require('worker_threads'); | ||
|
||
// This test makes sure that we manipulate the references of | ||
// `parentPort` correctly so that any worker threads will | ||
// automatically exit when there are no any other references. | ||
{ | ||
if (isMainThread) { | ||
const worker = new Worker(__filename); | ||
|
||
worker.on('exit', common.mustCall((code) => { | ||
assert.strictEqual(code, 0); | ||
}), 1); | ||
|
||
worker.on('online', common.mustCall()); | ||
} else { | ||
const messageCallback = () => {}; | ||
parentPort.on('message', messageCallback); | ||
// The thread won't exit if we don't make the 'message' listener off. | ||
parentPort.off('message', messageCallback); | ||
} | ||
} |