forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
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: nodejs#26463 PR-URL: nodejs#26487 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- 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); | ||
})); | ||
} |