Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
worker: do not look up context twice in PostMessage
Refs: #38780 (comment)

PR-URL: #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>
  • Loading branch information
addaleax authored and aduh95 committed Jun 2, 2021
commit bcf73d651ac5729a11560ea6cc7121569d9c26a9
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