Skip to content

Commit

Permalink
src: make workers messaging more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
juanarbol committed May 3, 2021
1 parent 68e6673 commit c4233b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void OnFatalError(const char* location, const char* message);
V(ERR_VM_MODULE_LINK_FAILURE, Error) \
V(ERR_WASI_NOT_STARTED, Error) \
V(ERR_WORKER_INIT_FAILED, Error) \
V(ERR_WORKER_MESSAGEPORT_CLOSED, Error) \
V(ERR_PROTO_ACCESS, Error)

#define V(code, type) \
Expand Down Expand Up @@ -166,6 +167,7 @@ ERRORS_WITH_CODE(V)
V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, "Failed to set PSK identity hint") \
V(ERR_WASI_NOT_STARTED, "wasi.start() has not been called") \
V(ERR_WORKER_INIT_FAILED, "Worker initialization failure") \
V(ERR_WORKER_MESSAGEPORT_CLOSED, "Worker messageport closed") \
V(ERR_PROTO_ACCESS, \
"Accessing Object.prototype.__proto__ has been " \
"disallowed with --disable-proto=throw")
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) {
Isolate* isolate = env->isolate();
THROW_ERR_WORKER_MESSAGEPORT_CLOSED(isolate);
return;
}

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

0 comments on commit c4233b4

Please sign in to comment.