@@ -489,8 +489,12 @@ Maybe<bool> Message::Serialize(Environment* env,
489
489
Local<Object> entry = entry_val.As <Object>();
490
490
// See https://github.com/nodejs/node/pull/30339#issuecomment-552225353
491
491
// for details.
492
- if (entry->HasPrivate (context, env->untransferable_object_private_symbol ())
493
- .ToChecked ()) {
492
+ bool ans;
493
+ if (!entry->HasPrivate (context, env->untransferable_object_private_symbol ())
494
+ .To (&ans)) {
495
+ return Nothing<bool >();
496
+ }
497
+ if (ans) {
494
498
ThrowDataCloneException (context, env->transfer_unsupported_type_str ());
495
499
return Nothing<bool >();
496
500
}
@@ -588,7 +592,9 @@ Maybe<bool> Message::Serialize(Environment* env,
588
592
for (Local<ArrayBuffer> ab : array_buffers) {
589
593
// If serialization succeeded, we render it inaccessible in this Isolate.
590
594
std::shared_ptr<BackingStore> backing_store = ab->GetBackingStore ();
591
- ab->Detach (Local<Value>()).Check ();
595
+ if (ab->Detach (Local<Value>()).IsNothing ()) {
596
+ return Nothing<bool >();
597
+ }
592
598
593
599
array_buffers_.emplace_back (std::move (backing_store));
594
600
}
@@ -1069,7 +1075,10 @@ bool GetTransferList(Environment* env,
1069
1075
void MessagePort::PostMessage (const FunctionCallbackInfo<Value>& args) {
1070
1076
Environment* env = Environment::GetCurrent (args);
1071
1077
Local<Object> obj = args.This ();
1072
- Local<Context> context = obj->GetCreationContextChecked ();
1078
+ Local<Context> context;
1079
+ if (!obj->GetCreationContext ().ToLocal (&context)) {
1080
+ return ;
1081
+ }
1073
1082
1074
1083
if (args.Length () == 0 ) {
1075
1084
return THROW_ERR_MISSING_ARGS (env, " Not enough arguments to "
@@ -1156,11 +1165,15 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
1156
1165
return ;
1157
1166
}
1158
1167
1159
- MaybeLocal<Value> payload =
1160
- port->ReceiveMessage (port->object ()->GetCreationContextChecked (),
1161
- MessageProcessingMode::kForceReadMessages );
1162
- if (!payload.IsEmpty ())
1163
- args.GetReturnValue ().Set (payload.ToLocalChecked ());
1168
+ Local<Value> payload;
1169
+ Local<Context> context;
1170
+ if (!port->object ()->GetCreationContext ().ToLocal (&context)) {
1171
+ return ;
1172
+ }
1173
+ if (port->ReceiveMessage (context, MessageProcessingMode::kForceReadMessages )
1174
+ .ToLocal (&payload)) {
1175
+ args.GetReturnValue ().Set (payload);
1176
+ }
1164
1177
}
1165
1178
1166
1179
void MessagePort::MoveToContext (const FunctionCallbackInfo<Value>& args) {
@@ -1616,7 +1629,10 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
1616
1629
return ;
1617
1630
}
1618
1631
1619
- Local<Context> context = args.This ()->GetCreationContextChecked ();
1632
+ Local<Context> context;
1633
+ if (!args.This ()->GetCreationContext ().ToLocal (&context)) {
1634
+ return ;
1635
+ }
1620
1636
Context::Scope context_scope (context);
1621
1637
1622
1638
MessagePort* port1 = MessagePort::New (env, context);
0 commit comments