-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: remove
ERR_CLOSED_MESSAGE_PORT
This aligns `MessagePort`s more with the web API. Refs: #26463 PR-URL: #26487 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
- Loading branch information
Showing
4 changed files
with
41 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { MessageChannel } = require('worker_threads'); | ||
|
||
// Make sure that .start() and .stop() do not throw on closing/closed | ||
// MessagePorts. | ||
// Refs: https://github.com/nodejs/node/issues/26463 | ||
|
||
function dummy() {} | ||
|
||
{ | ||
const { port1, port2 } = new MessageChannel(); | ||
port1.close(common.mustCall(() => { | ||
port1.on('message', dummy); | ||
port1.off('message', dummy); | ||
port2.on('message', dummy); | ||
port2.off('message', dummy); | ||
})); | ||
port1.on('message', dummy); | ||
port1.off('message', dummy); | ||
port2.on('message', dummy); | ||
port2.off('message', dummy); | ||
} | ||
|
||
{ | ||
const { port1 } = new MessageChannel(); | ||
port1.on('message', dummy); | ||
port1.close(common.mustCall(() => { | ||
port1.off('message', dummy); | ||
})); | ||
} |