GeezerVison is showing github.com — Revert "worker: remove `ERR_CLOSED_MESSAGE_PORT`" · subson/node@b373a2c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/errors.md +6Lines changed: 6 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -714,6 +714,12 @@ Used when a child process is being forked without specifying an IPC channel. |
714 | 714 | Used when the main process is trying to read data from the child process's |
715 | 715 | STDERR/STDOUT, and the data's length is longer than the `maxBuffer` option. |
716 | 716 |
|
| 717 | +<a id="ERR_CLOSED_MESSAGE_PORT"></a> |
| 718 | +### ERR_CLOSED_MESSAGE_PORT |
| 719 | + |
| 720 | +There was an attempt to use a `MessagePort` instance in a closed |
| 721 | +state, usually after `.close()` has been called. |
| 722 | + |
717 | 723 | <a id="ERR_CONSOLE_WRITABLE_STREAM"></a> |
718 | 724 | ### `ERR_CONSOLE_WRITABLE_STREAM` |
719 | 725 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_errors.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,6 +32,7 @@ void OnFatalError(const char* location, const char* message); |
32 | 32 | V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \ |
33 | 33 | V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \ |
34 | 34 | V(ERR_BUFFER_TOO_LARGE, Error) \ |
| 35 | + V(ERR_CLOSED_MESSAGE_PORT, Error) \ |
35 | 36 | V(ERR_CONSTRUCT_CALL_REQUIRED, TypeError) \ |
36 | 37 | V(ERR_CONSTRUCT_CALL_INVALID, TypeError) \ |
37 | 38 | V(ERR_CRYPTO_INITIALIZATION_FAILED, Error) \ |
@@ -118,6 +119,7 @@ ERRORS_WITH_CODE(V) |
118 | 119 | #define PREDEFINED_ERROR_MESSAGES(V) \ |
119 | 120 | V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \ |
120 | 121 | "Buffer is not available for the current Context") \ |
| 122 | + V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \ |
121 | 123 | V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \ |
122 | 124 | V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \ |
123 | 125 | V(ERR_CRYPTO_INITIALIZATION_FAILED, "Initialization failed") \ |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_messaging.cc +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1065,7 +1065,11 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo<Value>& args) { |
1065 | 1065 | "The \"port\" argument must be a MessagePort instance"); |
1066 | 1066 | } |
1067 | 1067 | MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>()); |
1068 | | - CHECK_NOT_NULL(port); |
| 1068 | + if (port == nullptr || port->IsHandleClosing()) { |
| 1069 | + Isolate* isolate = env->isolate(); |
| 1070 | + THROW_ERR_CLOSED_MESSAGE_PORT(isolate); |
| 1071 | + return; |
| 1072 | + } |
1069 | 1073 |
|
1070 | 1074 | Local<Value> context_arg = args[1]; |
1071 | 1075 | ContextifyContext* context_wrapper; |
|