diff --git a/src/node.cc b/src/node.cc index 7a585646f66ec4..e559f2232666ed 100644 --- a/src/node.cc +++ b/src/node.cc @@ -240,6 +240,7 @@ static struct { } void Dispose() { + StopTracingAgent(); platform_->Shutdown(); delete platform_; platform_ = nullptr; @@ -579,7 +580,6 @@ static void WaitForInspectorDisconnect(Environment* env) { void Exit(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); WaitForInspectorDisconnect(env); - v8_platform.StopTracingAgent(); int code = args[0]->Int32Value(env->context()).FromMaybe(0); env->Exit(code); } @@ -1436,7 +1436,6 @@ int Start(int argc, char** argv) { per_process::v8_initialized = true; const int exit_code = Start(uv_default_loop(), args, exec_args); - v8_platform.StopTracingAgent(); per_process::v8_initialized = false; V8::Dispose(); diff --git a/src/node_errors.cc b/src/node_errors.cc index 9ffd8d88f1e473..4a9a08e15021d6 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -322,7 +322,7 @@ TryCatchScope::~TryCatchScope() { if (HasCaught() && !HasTerminated() && mode_ == CatchMode::kFatal) { HandleScope scope(env_->isolate()); ReportException(env_, Exception(), Message()); - exit(7); + env_->Exit(7); } } @@ -381,7 +381,7 @@ void FatalException(Isolate* isolate, // Failed before the process._fatalException function was added! // this is probably pretty bad. Nothing to do but report and exit. ReportException(env, error, message); - exit(6); + env->Exit(6); } else { errors::TryCatchScope fatal_try_catch(env); @@ -397,7 +397,7 @@ void FatalException(Isolate* isolate, if (fatal_try_catch.HasCaught()) { // The fatal exception function threw, so we must exit ReportException(env, fatal_try_catch); - exit(7); + env->Exit(7); } else if (caught.ToLocalChecked()->IsFalse()) { ReportException(env, error, message); @@ -408,9 +408,9 @@ void FatalException(Isolate* isolate, Local code; if (!process_object->Get(env->context(), exit_code).ToLocal(&code) || !code->IsInt32()) { - exit(1); + env->Exit(1); } - exit(code.As()->Value()); + env->Exit(code.As()->Value()); } } }