Skip to content

Commit

Permalink
worker: do not look up context twice in PostMessage
Browse files Browse the repository at this point in the history
Refs: #38780 (comment)

PR-URL: #38784
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
  • Loading branch information
addaleax authored and targos committed Jun 11, 2021
1 parent a71df76 commit f959cb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>();

Expand Down Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions src/node_messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f959cb3

Please sign in to comment.