diff --git a/src/api/environment.cc b/src/api/environment.cc index b906fe10385b94..86498671b5df02 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -797,6 +797,10 @@ void DefaultProcessExitHandler(Environment* env, int exit_code) { env->set_can_call_into_js(false); env->stop_sub_worker_contexts(); env->isolate()->DumpAndResetStats(); + // The tracing agent could be in the process of writing data using the + // threadpool. Stop it before shutting down libuv. The rest of the tracing + // agent disposal will be performed in DisposePlatform(). + per_process::v8_platform.StopTracingAgent(); // When the process exits, the tasks in the thread pool may also need to // access the data of V8Platform, such as trace agent, or a field // added in the future. So make sure the thread pool exits first.