Skip to content

Commit

Permalink
src: Handle bad callback in asyc_wrap
Browse files Browse the repository at this point in the history
Align with the MaybeLocal<> API contract
  • Loading branch information
HarshithaKP committed Feb 27, 2020
1 parent 9c70292 commit fc53c8d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/async_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "async_wrap.h"
#include "base_object-inl.h"
#include "node_errors.h"
#include "node_internals.h"

namespace node {
Expand Down Expand Up @@ -74,9 +75,8 @@ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v))
return v8::MaybeLocal<v8::Value>();
if (!cb_v->IsFunction()) {
// TODO(addaleax): We should throw an error here to fulfill the
// `MaybeLocal<>` API contract.
return v8::MaybeLocal<v8::Value>();
v8::Isolate* isolate = env()->isolate();
return Undefined(isolate);
}
return MakeCallback(cb_v.As<v8::Function>(), argc, argv);
}
Expand Down

0 comments on commit fc53c8d

Please sign in to comment.