@@ -241,8 +241,10 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
241
241
uint32_t len = export_names_arr->Length ();
242
242
LocalVector<String> export_names (realm->isolate (), len);
243
243
for (uint32_t i = 0 ; i < len; i++) {
244
- Local<Value> export_name_val =
245
- export_names_arr->Get (context, i).ToLocalChecked ();
244
+ Local<Value> export_name_val;
245
+ if (!export_names_arr->Get (context, i).ToLocal (&export_name_val)) {
246
+ return ;
247
+ }
246
248
CHECK (export_name_val->IsString ());
247
249
export_names[i] = export_name_val.As <String>();
248
250
}
@@ -612,7 +614,10 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
612
614
return ;
613
615
}
614
616
615
- args.GetReturnValue ().Set (result.ToLocalChecked ());
617
+ Local<Value> res;
618
+ if (result.ToLocal (&res)) {
619
+ args.GetReturnValue ().Set (res);
620
+ }
616
621
}
617
622
618
623
void ModuleWrap::InstantiateSync (const FunctionCallbackInfo<Value>& args) {
@@ -862,10 +867,10 @@ static MaybeLocal<Promise> ImportModuleDynamically(
862
867
// from the realm global object.
863
868
if (options->Length () == HostDefinedOptions::kLength ) {
864
869
id = options->Get (context, HostDefinedOptions::kID ).As <Symbol>();
865
- } else {
866
- id = context-> Global ( )
867
- -> GetPrivate (context, env-> host_defined_option_symbol ())
868
- . ToLocalChecked ();
870
+ } else if (!context-> Global ()
871
+ -> GetPrivate ( context, env-> host_defined_option_symbol () )
872
+ . ToLocal (&id)) {
873
+ return MaybeLocal<Promise> ();
869
874
}
870
875
871
876
Local<Object> attributes =
@@ -985,7 +990,9 @@ MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
985
990
return MaybeLocal<Value>();
986
991
}
987
992
988
- resolver->Resolve (context, Undefined (isolate)).ToChecked ();
993
+ if (resolver->Resolve (context, Undefined (isolate)).IsNothing ()) {
994
+ return MaybeLocal<Value>();
995
+ }
989
996
return resolver->GetPromise ();
990
997
}
991
998
@@ -1027,15 +1034,18 @@ void ModuleWrap::CreateCachedData(const FunctionCallbackInfo<Value>& args) {
1027
1034
std::unique_ptr<ScriptCompiler::CachedData> cached_data (
1028
1035
ScriptCompiler::CreateCodeCache (unbound_module_script));
1029
1036
Environment* env = Environment::GetCurrent (args);
1037
+ Local<Object> result;
1030
1038
if (!cached_data) {
1031
- args.GetReturnValue ().Set (Buffer::New (env, 0 ).ToLocalChecked ());
1032
- } else {
1033
- MaybeLocal<Object> buf =
1034
- Buffer::Copy (env,
1035
- reinterpret_cast <const char *>(cached_data->data ),
1036
- cached_data->length );
1037
- args.GetReturnValue ().Set (buf.ToLocalChecked ());
1039
+ if (!Buffer::New (env, 0 ).ToLocal (&result)) {
1040
+ return ;
1041
+ }
1042
+ } else if (!Buffer::Copy (env,
1043
+ reinterpret_cast <const char *>(cached_data->data ),
1044
+ cached_data->length )
1045
+ .ToLocal (&result)) {
1046
+ return ;
1038
1047
}
1048
+ args.GetReturnValue ().Set (result);
1039
1049
}
1040
1050
1041
1051
// This v8::Module::ResolveModuleCallback simply links `import 'original'`
@@ -1082,8 +1092,10 @@ void ModuleWrap::CreateRequiredModuleFacade(
1082
1092
1083
1093
// The module facade instantiation simply links `import 'original'` in the
1084
1094
// facade with the original module and should never fail.
1085
- Local<Module> facade =
1086
- ScriptCompiler::CompileModule (isolate, &source).ToLocalChecked ();
1095
+ Local<Module> facade;
1096
+ if (!ScriptCompiler::CompileModule (isolate, &source).ToLocal (&facade)) {
1097
+ return ;
1098
+ }
1087
1099
// Stash the original module in temporary_required_module_facade_original
1088
1100
// for the LinkRequireFacadeWithOriginal() callback to pick it up.
1089
1101
CHECK (env->temporary_required_module_facade_original .IsEmpty ());
@@ -1094,7 +1106,10 @@ void ModuleWrap::CreateRequiredModuleFacade(
1094
1106
env->temporary_required_module_facade_original .Reset ();
1095
1107
1096
1108
// The evaluation of the facade is synchronous.
1097
- Local<Value> evaluated = facade->Evaluate (context).ToLocalChecked ();
1109
+ Local<Value> evaluated;
1110
+ if (!facade->Evaluate (context).ToLocal (&evaluated)) {
1111
+ return ;
1112
+ }
1098
1113
CHECK (evaluated->IsPromise ());
1099
1114
CHECK_EQ (evaluated.As <Promise>()->State (), Promise::PromiseState::kFulfilled );
1100
1115
0 commit comments