From fc53c8d524452f38ef59e41ad40fd903c5bb08ca Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Tue, 25 Feb 2020 02:46:16 -0500 Subject: [PATCH 1/2] src: Handle bad callback in asyc_wrap Align with the MaybeLocal<> API contract --- src/async_wrap-inl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/async_wrap-inl.h b/src/async_wrap-inl.h index e3e48666e4fbd6..9f46e2fe26c34b 100644 --- a/src/async_wrap-inl.h +++ b/src/async_wrap-inl.h @@ -26,6 +26,7 @@ #include "async_wrap.h" #include "base_object-inl.h" +#include "node_errors.h" #include "node_internals.h" namespace node { @@ -74,9 +75,8 @@ inline v8::MaybeLocal AsyncWrap::MakeCallback( if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v)) return v8::MaybeLocal(); if (!cb_v->IsFunction()) { - // TODO(addaleax): We should throw an error here to fulfill the - // `MaybeLocal<>` API contract. - return v8::MaybeLocal(); + v8::Isolate* isolate = env()->isolate(); + return Undefined(isolate); } return MakeCallback(cb_v.As(), argc, argv); } From b8f1ec799d25343fc0b1ddbcb4b33d77cbf1bf40 Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Fri, 28 Feb 2020 03:13:21 -0500 Subject: [PATCH 2/2] fixup: address review comment --- src/async_wrap-inl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/async_wrap-inl.h b/src/async_wrap-inl.h index 9f46e2fe26c34b..03745081f3b09b 100644 --- a/src/async_wrap-inl.h +++ b/src/async_wrap-inl.h @@ -26,7 +26,6 @@ #include "async_wrap.h" #include "base_object-inl.h" -#include "node_errors.h" #include "node_internals.h" namespace node {