File tree Expand file tree Collapse file tree 4 files changed +41
-10
lines changed Expand file tree Collapse file tree 4 files changed +41
-10
lines changed Original file line number Diff line number Diff line change @@ -688,12 +688,6 @@ Used when a child process is being forked without specifying an IPC channel.
688688Used when the main process is trying to read data from the child process's
689689STDERR/STDOUT, and the data's length is longer than the ` maxBuffer ` option.
690690
691- <a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
692- ### ERR_CLOSED_MESSAGE_PORT
693-
694- There was an attempt to use a ` MessagePort ` instance in a closed
695- state, usually after ` .close() ` has been called.
696-
697691<a id =" ERR_CONSOLE_WRITABLE_STREAM " ></a >
698692### ERR_CONSOLE_WRITABLE_STREAM
699693
@@ -1986,6 +1980,16 @@ A module file could not be resolved while attempting a [`require()`][] or
19861980> Stability: 0 - Deprecated. These error codes are either inconsistent, or have
19871981> been removed.
19881982
1983+ <a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
1984+ ### ERR_CLOSED_MESSAGE_PORT
1985+ <!-- YAML
1986+ added: v10.5.0
1987+ removed: REPLACEME
1988+ -->
1989+
1990+ There was an attempt to use a ` MessagePort ` instance in a closed
1991+ state, usually after ` .close() ` has been called.
1992+
19891993<a id =" ERR_HTTP2_FRAME_ERROR " ></a >
19901994### ERR_HTTP2_FRAME_ERROR
19911995<!-- YAML
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ void FatalException(v8::Isolate* isolate,
4242 V (ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
4343 V (ERR_BUFFER_TOO_LARGE, Error) \
4444 V (ERR_CANNOT_TRANSFER_OBJECT, TypeError) \
45- V (ERR_CLOSED_MESSAGE_PORT, Error) \
4645 V (ERR_CONSTRUCT_CALL_REQUIRED, Error) \
4746 V (ERR_INVALID_ARG_VALUE, TypeError) \
4847 V (ERR_INVALID_ARG_TYPE, TypeError) \
@@ -86,7 +85,6 @@ void FatalException(v8::Isolate* isolate,
8685 V (ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
8786 " Buffer is not available for the current Context" ) \
8887 V (ERR_CANNOT_TRANSFER_OBJECT, " Cannot transfer object of unsupported type" )\
89- V (ERR_CLOSED_MESSAGE_PORT, " Cannot send data on closed MessagePort" ) \
9088 V (ERR_CONSTRUCT_CALL_REQUIRED, " Cannot call constructor without `new`" ) \
9189 V (ERR_INVALID_TRANSFER_OBJECT, " Found invalid object in transferList" ) \
9290 V (ERR_MEMORY_ALLOCATION_FAILED, " Failed to allocate memory" ) \
Original file line number Diff line number Diff line change @@ -729,7 +729,6 @@ void MessagePort::Start(const FunctionCallbackInfo<Value>& args) {
729729 MessagePort* port;
730730 ASSIGN_OR_RETURN_UNWRAP (&port, args.This ());
731731 if (!port->data_ ) {
732- THROW_ERR_CLOSED_MESSAGE_PORT (env);
733732 return ;
734733 }
735734 port->Start ();
@@ -741,7 +740,6 @@ void MessagePort::Stop(const FunctionCallbackInfo<Value>& args) {
741740 CHECK (args[0 ]->IsObject ());
742741 ASSIGN_OR_RETURN_UNWRAP (&port, args[0 ].As <Object>());
743742 if (!port->data_ ) {
744- THROW_ERR_CLOSED_MESSAGE_PORT (env);
745743 return ;
746744 }
747745 port->Stop ();
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const { MessageChannel } = require ( 'worker_threads' ) ;
4+
5+ // Make sure that .start() and .stop() do not throw on closing/closed
6+ // MessagePorts.
7+ // Refs: https://github.com/nodejs/node/issues/26463
8+
9+ function dummy ( ) { }
10+
11+ {
12+ const { port1, port2 } = new MessageChannel ( ) ;
13+ port1 . close ( common . mustCall ( ( ) => {
14+ port1 . on ( 'message' , dummy ) ;
15+ port1 . off ( 'message' , dummy ) ;
16+ port2 . on ( 'message' , dummy ) ;
17+ port2 . off ( 'message' , dummy ) ;
18+ } ) ) ;
19+ port1 . on ( 'message' , dummy ) ;
20+ port1 . off ( 'message' , dummy ) ;
21+ port2 . on ( 'message' , dummy ) ;
22+ port2 . off ( 'message' , dummy ) ;
23+ }
24+
25+ {
26+ const { port1 } = new MessageChannel ( ) ;
27+ port1 . on ( 'message' , dummy ) ;
28+ port1 . close ( common . mustCall ( ( ) => {
29+ port1 . off ( 'message' , dummy ) ;
30+ } ) ) ;
31+ }
You can’t perform that action at this time.
0 commit comments