Skip to content

Commit e00b326

Browse files
addaleaxtargos
authored andcommitted
src: pass along MaybeLocal<> state from URL::ToObject()
PR-URL: #25141 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent ae86192 commit e00b326

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/module_wrap.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo<Value>& args) {
708708
return node::THROW_ERR_MISSING_MODULE(env, msg.c_str());
709709
}
710710

711-
args.GetReturnValue().Set(result.FromJust().ToObject(env));
711+
MaybeLocal<Value> obj = result.FromJust().ToObject(env);
712+
if (!obj.IsEmpty())
713+
args.GetReturnValue().Set(obj.ToLocalChecked());
712714
}
713715

714716
static MaybeLocal<Promise> ImportModuleDynamically(

src/node_url.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ URL URL::FromFilePath(const std::string& file_path) {
23812381
// This function works by calling out to a JS function that creates and
23822382
// returns the JS URL object. Be mindful of the JS<->Native boundary
23832383
// crossing that is required.
2384-
const Local<Value> URL::ToObject(Environment* env) const {
2384+
MaybeLocal<Value> URL::ToObject(Environment* env) const {
23852385
Isolate* isolate = env->isolate();
23862386
Local<Context> context = env->context();
23872387
Context::Scope context_scope(context);
@@ -2417,7 +2417,7 @@ const Local<Value> URL::ToObject(Environment* env) const {
24172417
->Call(env->context(), undef, arraysize(argv), argv);
24182418
}
24192419

2420-
return ret.ToLocalChecked();
2420+
return ret;
24212421
}
24222422

24232423
static void SetURLConstructor(const FunctionCallbackInfo<Value>& args) {

src/node_url.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
namespace node {
1212
namespace url {
1313

14-
using v8::Local;
15-
using v8::Value;
16-
17-
1814
#define PARSESTATES(XX) \
1915
XX(kSchemeStart) \
2016
XX(kScheme) \
@@ -171,7 +167,7 @@ class URL {
171167
// Get the file URL from native file system path.
172168
static URL FromFilePath(const std::string& file_path);
173169

174-
const Local<Value> ToObject(Environment* env) const;
170+
v8::MaybeLocal<v8::Value> ToObject(Environment* env) const;
175171

176172
URL(const URL&) = default;
177173
URL& operator=(const URL&) = default;

0 commit comments

Comments
 (0)