From 906d279e697af654cb731d3ca9079bb3c52080e7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 2 Nov 2019 21:11:40 +0100 Subject: [PATCH] src: run RunBeforeExitCallbacks as part of EmitBeforeExit This is part of a series of changes to make embedding easier, by requiring fewer internal methods to build a fully functioning Node.js instance. This also aligns the worker_threads code with the main thread code. PR-URL: https://github.com/nodejs/node/pull/30229 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Joyee Cheung Reviewed-By: Shelley Vohr --- src/api/hooks.cc | 2 ++ src/node_main_instance.cc | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/hooks.cc b/src/api/hooks.cc index cec58cee00847c..2dd0cc994ea7f2 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -30,6 +30,8 @@ void AtExit(Environment* env, void (*cb)(void* arg), void* arg) { } void EmitBeforeExit(Environment* env) { + env->RunBeforeExitCallbacks(); + HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local exit_code = env->process_object() diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index a4b2853b7c9b9f..eea847725300f0 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -140,8 +140,6 @@ int NodeMainInstance::Run() { more = uv_loop_alive(env->event_loop()); if (more && !env->is_stopping()) continue; - env->RunBeforeExitCallbacks(); - if (!uv_loop_alive(env->event_loop())) { EmitBeforeExit(env.get()); }