diff --git a/src/env.cc b/src/env.cc index 8f061f9f83f288..3daf75e13043f6 100644 --- a/src/env.cc +++ b/src/env.cc @@ -673,10 +673,13 @@ void Environment::AsyncHooks::grow_async_ids_stack() { uv_key_t Environment::thread_local_env = {}; void Environment::Exit(int exit_code) { - if (is_main_thread()) + if (is_main_thread()) { + stop_sub_worker_contexts(); + DisposePlatform(); exit(exit_code); - else + } else { worker_context_->Exit(exit_code); + } } void Environment::stop_sub_worker_contexts() { diff --git a/src/node.cc b/src/node.cc index 9fb5ab3b8e1d3d..9390215b1b3065 100644 --- a/src/node.cc +++ b/src/node.cc @@ -383,6 +383,10 @@ static struct { #endif // !NODE_USE_V8_PLATFORM || !HAVE_INSPECTOR } v8_platform; +void DisposePlatform() { + v8_platform.Dispose(); +} + #ifdef __POSIX__ static const unsigned kMaxSignal = 32; #endif diff --git a/src/node_internals.h b/src/node_internals.h index 12089bc5f4af62..95b691884ec2b2 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -538,6 +538,8 @@ int ThreadPoolWork::CancelWork() { return uv_cancel(reinterpret_cast(&work_req_)); } +void DisposePlatform(); + static inline const char* errno_string(int errorno) { #define ERRNO_CASE(e) case e: return #e; switch (errorno) {