diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 3860ec745e0311..243352fe644e40 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -708,7 +708,9 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo& args) { return node::THROW_ERR_MISSING_MODULE(env, msg.c_str()); } - args.GetReturnValue().Set(result.FromJust().ToObject(env)); + MaybeLocal obj = result.FromJust().ToObject(env); + if (!obj.IsEmpty()) + args.GetReturnValue().Set(obj.ToLocalChecked()); } static MaybeLocal ImportModuleDynamically( diff --git a/src/node_url.cc b/src/node_url.cc index d5dba61ae4cc84..d028a66dbea542 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -2381,7 +2381,7 @@ URL URL::FromFilePath(const std::string& file_path) { // This function works by calling out to a JS function that creates and // returns the JS URL object. Be mindful of the JS<->Native boundary // crossing that is required. -const Local URL::ToObject(Environment* env) const { +MaybeLocal URL::ToObject(Environment* env) const { Isolate* isolate = env->isolate(); Local context = env->context(); Context::Scope context_scope(context); @@ -2417,7 +2417,7 @@ const Local URL::ToObject(Environment* env) const { ->Call(env->context(), undef, arraysize(argv), argv); } - return ret.ToLocalChecked(); + return ret; } static void SetURLConstructor(const FunctionCallbackInfo& args) { diff --git a/src/node_url.h b/src/node_url.h index 055393d22e0f19..47b859b879bca4 100644 --- a/src/node_url.h +++ b/src/node_url.h @@ -11,10 +11,6 @@ namespace node { namespace url { -using v8::Local; -using v8::Value; - - #define PARSESTATES(XX) \ XX(kSchemeStart) \ XX(kScheme) \ @@ -171,7 +167,7 @@ class URL { // Get the file URL from native file system path. static URL FromFilePath(const std::string& file_path); - const Local ToObject(Environment* env) const; + v8::MaybeLocal ToObject(Environment* env) const; URL(const URL&) = default; URL& operator=(const URL&) = default;