Skip to content

Commit

Permalink
Revert "worker: remove ERR_CLOSED_MESSAGE_PORT"
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
juanarbol authored and targos committed May 17, 2021
1 parent 352a600 commit 070ee4b
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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_INITIALIZATION_FAILED, Error) \
Expand Down Expand Up @@ -118,6 +119,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_INITIALIZATION_FAILED, "Initialization failed") \
Expand Down
6 changes: 5 additions & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,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 070ee4b

Please sign in to comment.