Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <cstdlib>
#if HAVE_OPENSSL
#include "crypto/crypto_util.h"
#endif // HAVE_OPENSSL
#include "env_properties.h"
#include "node.h"
#include "node_builtins.h"
Expand Down Expand Up @@ -1004,6 +1007,11 @@ void DefaultProcessExitHandlerInternal(Environment* env, ExitCode exit_code) {
// in node_v8_platform-inl.h
uv_library_shutdown();
DisposePlatform();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that in the normal exit path, this is done separately and guarded by kNoInitializeNodeV8Platform

node/src/node.cc

Lines 1312 to 1321 in ca76b39

if (!(flags & ProcessInitializationFlags::kNoInitializeNodeV8Platform)) {
V8::DisposePlatform();
// uv_run cannot be called from the time before the beforeExit callback
// runs until the program exits unless the event loop has any referenced
// handles after beforeExit terminates. This prevents unrefed timers
// that happen to terminate during shutdown from being run unsafely.
// Since uv_run cannot be called, uv_async handles held by the platform
// will never be fully cleaned up.
per_process::v8_platform.Dispose();
}

Maybe we should wrap the things that need to be done both on normal and abnormal exit into a helper and call them in both DefaultProcessExitHandlerInternal and TearDownOncePerProcess?

(Also, from what I can tell, this function would only get called on the main thread - it would be better to assert it, most things in this section can only be called once by one thread)


#if HAVE_OPENSSL
crypto::CleanupCachedRootCertificates();
#endif // HAVE_OPENSSL

Exit(exit_code);
}

Expand Down
Loading