diff --git a/src/node_errors.h b/src/node_errors.h index 291365fa3b4dc9..050fb298877116 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -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) \ @@ -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") diff --git a/src/node_messaging.cc b/src/node_messaging.cc index fbe6c407a6cea2..fd853d36f7e6e6 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -1065,7 +1065,11 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo& args) { "The \"port\" argument must be a MessagePort instance"); } MessagePort* port = Unwrap(args[0].As()); - CHECK_NOT_NULL(port); + if (port == nullptr) { + Isolate* isolate = env->isolate(); + THROW_ERR_WORKER_MESSAGEPORT_CLOSED(isolate); + return; + } Local context_arg = args[1]; ContextifyContext* context_wrapper;