Skip to content
Closed
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
29 changes: 22 additions & 7 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,12 @@ Maybe<bool> Message::Serialize(Environment* env,
Local<Object> entry = entry_val.As<Object>();
// See https://github.com/nodejs/node/pull/30339#issuecomment-552225353
// for details.
if (entry->HasPrivate(context, env->untransferable_object_private_symbol())
.ToChecked()) {
bool ans;
if (!entry->HasPrivate(context, env->untransferable_object_private_symbol())
.To(&ans)) {
return Nothing<bool>();
}
if (ans) {
ThrowDataCloneException(context, env->transfer_unsupported_type_str());
return Nothing<bool>();
}
Expand Down Expand Up @@ -589,7 +593,9 @@ Maybe<bool> Message::Serialize(Environment* env,
for (Local<ArrayBuffer> ab : array_buffers) {
// If serialization succeeded, we render it inaccessible in this Isolate.
std::shared_ptr<BackingStore> backing_store = ab->GetBackingStore();
ab->Detach(Local<Value>()).Check();
if (ab->Detach(Local<Value>()).IsNothing()) {
return Nothing<bool>();
}

array_buffers_.emplace_back(std::move(backing_store));
}
Expand Down Expand Up @@ -1070,7 +1076,10 @@ bool GetTransferList(Environment* env,
void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Local<Object> obj = args.This();
Local<Context> context = obj->GetCreationContextChecked();
Local<Context> context;
if (!obj->GetCreationContext().ToLocal(&context)) {
return;
}

if (args.Length() == 0) {
return THROW_ERR_MISSING_ARGS(env, "Not enough arguments to "
Expand Down Expand Up @@ -1157,8 +1166,11 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
}

Local<Value> payload;
if (port->ReceiveMessage(port->object()->GetCreationContextChecked(),
MessageProcessingMode::kForceReadMessages)
Local<Context> context;
if (!port->object()->GetCreationContext().ToLocal(&context)) {
return;
}
if (port->ReceiveMessage(context, MessageProcessingMode::kForceReadMessages)
.ToLocal(&payload)) {
args.GetReturnValue().Set(payload);
}
Expand Down Expand Up @@ -1616,7 +1628,10 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
return;
}

Local<Context> context = args.This()->GetCreationContextChecked();
Local<Context> context;
if (!args.This()->GetCreationContext().ToLocal(&context)) {
return;
}
Context::Scope context_scope(context);

MessagePort* port1 = MessagePort::New(env, context);
Expand Down
Loading