File tree 4 files changed +41
-10
lines changed
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
@@ -1975,6 +1969,16 @@ A module file could not be resolved while attempting a [`require()`][] or
1975
1969
> Stability: 0 - Deprecated. These error codes are either inconsistent, or have
1976
1970
> been removed.
1977
1971
1972
+ <a id =" ERR_CLOSED_MESSAGE_PORT " ></a >
1973
+ ### ERR_CLOSED_MESSAGE_PORT
1974
+ <!-- YAML
1975
+ added: v10.5.0
1976
+ removed: REPLACEME
1977
+ -->
1978
+
1979
+ There was an attempt to use a ` MessagePort ` instance in a closed
1980
+ state, usually after ` .close() ` has been called.
1981
+
1978
1982
<a id =" ERR_HTTP2_FRAME_ERROR " ></a >
1979
1983
### ERR_HTTP2_FRAME_ERROR
1980
1984
<!-- YAML
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ void FatalException(const v8::FunctionCallbackInfo<v8::Value>& args);
44
44
V (ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
45
45
V (ERR_BUFFER_TOO_LARGE, Error) \
46
46
V (ERR_CANNOT_TRANSFER_OBJECT, TypeError) \
47
- V (ERR_CLOSED_MESSAGE_PORT, Error) \
48
47
V (ERR_CONSTRUCT_CALL_REQUIRED, Error) \
49
48
V (ERR_INVALID_ARG_VALUE, TypeError) \
50
49
V (ERR_INVALID_ARG_TYPE, TypeError) \
@@ -87,7 +86,6 @@ void FatalException(const v8::FunctionCallbackInfo<v8::Value>& args);
87
86
V (ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
88
87
" Buffer is not available for the current Context" ) \
89
88
V (ERR_CANNOT_TRANSFER_OBJECT, " Cannot transfer object of unsupported type" )\
90
- V (ERR_CLOSED_MESSAGE_PORT, " Cannot send data on closed MessagePort" ) \
91
89
V (ERR_CONSTRUCT_CALL_REQUIRED, " Cannot call constructor without `new`" ) \
92
90
V (ERR_INVALID_TRANSFER_OBJECT, " Found invalid object in transferList" ) \
93
91
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