From bcf73d651ac5729a11560ea6cc7121569d9c26a9 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 23 May 2021 16:20:41 +0200 Subject: [PATCH] worker: do not look up context twice in PostMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/issues/38780#issuecomment-846548949 PR-URL: https://github.com/nodejs/node/pull/38784 Reviewed-By: Gireesh Punathil Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Minwoo Jung --- src/node_messaging.cc | 4 ++-- src/node_messaging.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 72f92b78dbf451..a1f28d4746d07f 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -840,11 +840,11 @@ BaseObjectPtr MessagePortData::Deserialize( } Maybe MessagePort::PostMessage(Environment* env, + Local context, Local message_v, const TransferList& transfer_v) { Isolate* isolate = env->isolate(); Local obj = object(isolate); - Local context = obj->GetCreationContext().ToLocalChecked(); std::shared_ptr msg = std::make_shared(); @@ -986,7 +986,7 @@ void MessagePort::PostMessage(const FunctionCallbackInfo& args) { return; } - Maybe res = port->PostMessage(env, args[0], transfer_list); + Maybe res = port->PostMessage(env, context, args[0], transfer_list); if (res.IsJust()) args.GetReturnValue().Set(res.FromJust()); } diff --git a/src/node_messaging.h b/src/node_messaging.h index eeef974ff353d5..643604e4a99f15 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -242,6 +242,7 @@ class MessagePort : public HandleWrap { // If this port is closed, or if there is no sibling, this message is // serialized with transfers, then silently discarded. v8::Maybe PostMessage(Environment* env, + v8::Local context, v8::Local message, const TransferList& transfer);