Skip to content

Commit ce139a0

Browse files
legendecasmhdawson
authored andcommitted
src: make failure of closing scopes fatal
Properly handle failures instead of ignoring them. PR-URL: #566 Reviewed-By: NickNaso <nicoladelgobbo@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
1 parent 740c798 commit ce139a0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

napi-inl.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,7 +3468,10 @@ inline HandleScope::HandleScope(Napi::Env env) : _env(env) {
34683468
}
34693469

34703470
inline HandleScope::~HandleScope() {
3471-
napi_close_handle_scope(_env, _scope);
3471+
napi_status status = napi_close_handle_scope(_env, _scope);
3472+
NAPI_FATAL_IF_FAILED(status,
3473+
"HandleScope::~HandleScope",
3474+
"napi_close_handle_scope");
34723475
}
34733476

34743477
inline HandleScope::operator napi_handle_scope() const {
@@ -3493,7 +3496,10 @@ inline EscapableHandleScope::EscapableHandleScope(Napi::Env env) : _env(env) {
34933496
}
34943497

34953498
inline EscapableHandleScope::~EscapableHandleScope() {
3496-
napi_close_escapable_handle_scope(_env, _scope);
3499+
napi_status status = napi_close_escapable_handle_scope(_env, _scope);
3500+
NAPI_FATAL_IF_FAILED(status,
3501+
"EscapableHandleScope::~EscapableHandleScope",
3502+
"napi_close_escapable_handle_scope");
34973503
}
34983504

34993505
inline EscapableHandleScope::operator napi_escapable_handle_scope() const {
@@ -3529,7 +3535,10 @@ inline CallbackScope::CallbackScope(napi_env env, napi_async_context context)
35293535
}
35303536

35313537
inline CallbackScope::~CallbackScope() {
3532-
napi_close_callback_scope(_env, _scope);
3538+
napi_status status = napi_close_callback_scope(_env, _scope);
3539+
NAPI_FATAL_IF_FAILED(status,
3540+
"CallbackScope::~CallbackScope",
3541+
"napi_close_callback_scope");
35333542
}
35343543

35353544
inline CallbackScope::operator napi_callback_scope() const {

0 commit comments

Comments
 (0)