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.
688
688
Used when the main process is trying to read data from the child process's
689
689
STDERR/STDOUT, and the data's length is longer than the ` maxBuffer ` option.
690
690
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
-
697
691
<a id =" ERR_CONSOLE_WRITABLE_STREAM " ></a >
698
692
### ERR_CONSOLE_WRITABLE_STREAM
699
693
@@ -1986,6 +1980,16 @@ A module file could not be resolved while attempting a [`require()`][] or
1986
1980
> Stability: 0 - Deprecated. These error codes are either inconsistent, or have
1987
1981
> been removed.
1988
1982
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
+
1989
1993
<a id =" ERR_HTTP2_FRAME_ERROR " ></a >
1990
1994
### ERR_HTTP2_FRAME_ERROR
1991
1995
<!-- YAML
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ void FatalException(v8::Isolate* isolate,
42
42
V (ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
43
43
V (ERR_BUFFER_TOO_LARGE, Error) \
44
44
V (ERR_CANNOT_TRANSFER_OBJECT, TypeError) \
45
- V (ERR_CLOSED_MESSAGE_PORT, Error) \
46
45
V (ERR_CONSTRUCT_CALL_REQUIRED, Error) \
47
46
V (ERR_INVALID_ARG_VALUE, TypeError) \
48
47
V (ERR_INVALID_ARG_TYPE, TypeError) \
@@ -86,7 +85,6 @@ void FatalException(v8::Isolate* isolate,
86
85
V (ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
87
86
" Buffer is not available for the current Context" ) \
88
87
V (ERR_CANNOT_TRANSFER_OBJECT, " Cannot transfer object of unsupported type" )\
89
- V (ERR_CLOSED_MESSAGE_PORT, " Cannot send data on closed MessagePort" ) \
90
88
V (ERR_CONSTRUCT_CALL_REQUIRED, " Cannot call constructor without `new`" ) \
91
89
V (ERR_INVALID_TRANSFER_OBJECT, " Found invalid object in transferList" ) \
92
90
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) {
729
729
MessagePort* port;
730
730
ASSIGN_OR_RETURN_UNWRAP (&port, args.This ());
731
731
if (!port->data_ ) {
732
- THROW_ERR_CLOSED_MESSAGE_PORT (env);
733
732
return ;
734
733
}
735
734
port->Start ();
@@ -741,7 +740,6 @@ void MessagePort::Stop(const FunctionCallbackInfo<Value>& args) {
741
740
CHECK (args[0 ]->IsObject ());
742
741
ASSIGN_OR_RETURN_UNWRAP (&port, args[0 ].As <Object>());
743
742
if (!port->data_ ) {
744
- THROW_ERR_CLOSED_MESSAGE_PORT (env);
745
743
return ;
746
744
}
747
745
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