-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 <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); | ||
})); | ||
} |