File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed
Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -715,7 +715,10 @@ Used when the main process is trying to read data from the child process's
715715STDERR/STDOUT, and the data's length is longer than the ` maxBuffer ` option.
716716
717717<a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
718- ### ERR_CLOSED_MESSAGE_PORT
718+ ### ` ERR_CLOSED_MESSAGE_PORT `
719+ <!--
720+ added: v10.5.0
721+ -->
719722
720723There was an attempt to use a ` MessagePort ` instance in a closed
721724state, usually after ` .close() ` has been called.
@@ -2466,16 +2469,6 @@ removed: v12.5.0
24662469The value passed to ` postMessage() ` contained an object that is not supported
24672470for transferring.
24682471
2469- <a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
2470- ### ` ERR_CLOSED_MESSAGE_PORT `
2471- <!-- YAML
2472- added: v10.5.0
2473- removed: v11.12.0
2474- -->
2475-
2476- There was an attempt to use a ` MessagePort ` instance in a closed
2477- state, usually after ` .close() ` has been called.
2478-
24792472<a id =" ERR_CRYPTO_HASH_DIGEST_NO_UTF16 " ></a >
24802473### ` ERR_CRYPTO_HASH_DIGEST_NO_UTF16 `
24812474<!-- YAML
Original file line number Diff line number Diff line change @@ -1066,7 +1066,7 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo<Value>& args) {
10661066 }
10671067 MessagePort* port = Unwrap<MessagePort>(args[0 ].As <Object>());
10681068 if (port == nullptr || port->IsHandleClosing ()) {
1069- Isolate* isolate = env->isolate ();
1069+ Isolate* isozlate = env->isolate ();
10701070 THROW_ERR_CLOSED_MESSAGE_PORT (isolate);
10711071 return ;
10721072 }
Original file line number Diff line number Diff line change 11'use strict' ;
22const common = require ( '../common' ) ;
3- const { MessageChannel } = require ( 'worker_threads' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const { MessageChannel, moveMessagePortToContext } = require ( 'worker_threads' ) ;
45
56// Make sure that .start() and .stop() do not throw on closing/closed
67// MessagePorts.
@@ -29,3 +30,12 @@ function dummy() {}
2930 port1 . off ( 'message' , dummy ) ;
3031 } ) ) ;
3132}
33+
34+ {
35+ const { port2 } = new MessageChannel ( ) ;
36+ port2 . close ( ) ;
37+ assert . throws ( ( ) => moveMessagePortToContext ( port2 , { } ) , {
38+ code : 'ERR_CLOSED_MESSAGE_PORT' ,
39+ message : 'Cannot send data on closed MessagePort'
40+ } ) ;
41+ }
You can’t perform that action at this time.
0 commit comments