Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "worker: remove ERR_CLOSED_MESSAGE_PORT"
This reverts commit 73370b4.

The unit test is preserved to make sure it does not break
#26463 again.

PR-URL: #38510
Fixes: #38499
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
juanarbol authored and targos committed Jun 11, 2021
1 parent cea8b42 commit 2c66305
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/api/errors.md
Expand Up @@ -714,6 +714,12 @@ Used when a child process is being forked without specifying an IPC channel.
Used when the main process is trying to read data from the child process's
STDERR/STDOUT, and the data's length is longer than the `maxBuffer` option.

<a id="ERR_CLOSED_MESSAGE_PORT"></a>
### ERR_CLOSED_MESSAGE_PORT

There was an attempt to use a `MessagePort` instance in a closed
state, usually after `.close()` has been called.

<a id="ERR_CONSOLE_WRITABLE_STREAM"></a>
### `ERR_CONSOLE_WRITABLE_STREAM`

Expand Down
2 changes: 2 additions & 0 deletions src/node_errors.h
Expand Up @@ -32,6 +32,7 @@ void OnFatalError(const char* location, const char* message);
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
V(ERR_BUFFER_TOO_LARGE, Error) \
V(ERR_CLOSED_MESSAGE_PORT, Error) \
V(ERR_CONSTRUCT_CALL_REQUIRED, TypeError) \
V(ERR_CONSTRUCT_CALL_INVALID, TypeError) \
V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, RangeError) \
Expand Down Expand Up @@ -98,6 +99,7 @@ ERRORS_WITH_CODE(V)
#define PREDEFINED_ERROR_MESSAGES(V) \
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
"Buffer is not available for the current Context") \
V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \
V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \
V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \
V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, \
Expand Down
6 changes: 5 additions & 1 deletion src/node_messaging.cc
Expand Up @@ -1040,7 +1040,11 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo<Value>& args) {
"The \"port\" argument must be a MessagePort instance");
}
MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>());
CHECK_NOT_NULL(port);
if (port == nullptr || port->IsHandleClosing()) {
Isolate* isolate = env->isolate();
THROW_ERR_CLOSED_MESSAGE_PORT(isolate);
return;
}

Local<Value> context_arg = args[1];
ContextifyContext* context_wrapper;
Expand Down

0 comments on commit 2c66305

Please sign in to comment.