diff --git a/src/node_worker.cc b/src/node_worker.cc index dc074885cb789d..88de33ce06ab4c 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -251,14 +251,6 @@ void Worker::Run() { Isolate::DisallowJavascriptExecutionScope disallow_js(isolate_, Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); - // Grab the parent-to-child channel and render is unusable. - MessagePort* child_port; - { - Mutex::ScopedLock lock(mutex_); - child_port = child_port_; - child_port_ = nullptr; - } - { Context::Scope context_scope(env_->context()); { @@ -394,13 +386,13 @@ void Worker::CreateEnvMessagePort(Environment* env) { HandleScope handle_scope(isolate_); Mutex::ScopedLock lock(mutex_); // Set up the message channel for receiving messages in the child. - child_port_ = MessagePort::New(env, - env->context(), - std::move(child_port_data_)); + MessagePort* child_port = MessagePort::New(env, + env->context(), + std::move(child_port_data_)); // MessagePort::New() may return nullptr if execution is terminated // within it. - if (child_port_ != nullptr) - env->set_message_port(child_port_->object(isolate_)); + if (child_port != nullptr) + env->set_message_port(child_port->object(isolate_)); } void Worker::JoinThread() { diff --git a/src/node_worker.h b/src/node_worker.h index 893e03db53f93e..744c31a9932174 100644 --- a/src/node_worker.h +++ b/src/node_worker.h @@ -100,9 +100,6 @@ class Worker : public AsyncWrap { std::unique_ptr child_port_data_; std::shared_ptr env_vars_; - // The child port is kept alive by the child Environment's persistent - // handle to it, as long as that child Environment exists. - MessagePort* child_port_ = nullptr; // This is always kept alive because the JS object associated with the Worker // instance refers to it via its [kPort] property. MessagePort* parent_port_ = nullptr;