diff options
author | Anna Henningsen <anna@addaleax.net> | 2021-05-23 17:20:41 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-06-11 08:23:51 +0300 |
commit | f959cb3c681cceebf7a3305db2f66970c3345d34 (patch) | |
tree | 44f279811b9f4426a81384aa80d6b11703ba4039 /src | |
parent | a71df7630e63de98bd88bbbd7171a8ffbd7850ef (diff) |
worker: do not look up context twice in PostMessage
Refs: https://github.com/nodejs/node/issues/38780#issuecomment-846548949
PR-URL: https://github.com/nodejs/node/pull/38784
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_messaging.cc | 4 | ||||
-rw-r--r-- | 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 72f92b78dbf..a1f28d4746d 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -840,11 +840,11 @@ BaseObjectPtr<BaseObject> MessagePortData::Deserialize( } Maybe<bool> MessagePort::PostMessage(Environment* env, + Local<Context> context, Local<Value> message_v, const TransferList& transfer_v) { Isolate* isolate = env->isolate(); Local<Object> obj = object(isolate); - Local<Context> context = obj->GetCreationContext().ToLocalChecked(); std::shared_ptr<Message> msg = std::make_shared<Message>(); @@ -986,7 +986,7 @@ void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) { return; } - Maybe<bool> res = port->PostMessage(env, args[0], transfer_list); + Maybe<bool> 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 eeef974ff35..643604e4a99 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<bool> PostMessage(Environment* env, + v8::Local<v8::Context> context, v8::Local<v8::Value> message, const TransferList& transfer); |