From 4a747f6037c7a589ae88b7a0238fea4218cce471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Thu, 1 Aug 2019 18:18:22 +0300 Subject: [PATCH] Revert "src: remove trace_sync_io_ from env" This reverts commit 7fa5f54e6f2854183e45e0e105a1e22a381aac60. The reverted commit breaks the logic behind --trace-sync-io, it should be enabled only at a certain point in time, while that commit enables it from the very start, causing warnings be printed for all sync io instead of sync io after the first tick of the event loop as documented. Fixes: https://github.com/nodejs/node/issues/28913 Refs: https://github.com/nodejs/node/pull/22726 Refs: https://nodejs.org/api/cli.html#cli_trace_sync_io PR-URL: https://github.com/nodejs/node/pull/28926 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/env-inl.h | 2 +- src/env.cc | 2 +- src/env.h | 1 + src/node_main_instance.cc | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 3d1aca994ffb03..a2ab98d66db10d 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -465,7 +465,7 @@ inline void Environment::set_printed_error(bool value) { } inline void Environment::set_trace_sync_io(bool value) { - options_->trace_sync_io = value; + trace_sync_io_ = value; } inline bool Environment::abort_on_uncaught_exception() const { diff --git a/src/env.cc b/src/env.cc index ca5e11ac558ace..257bf78519f32d 100644 --- a/src/env.cc +++ b/src/env.cc @@ -567,7 +567,7 @@ void Environment::StopProfilerIdleNotifier() { } void Environment::PrintSyncTrace() const { - if (!options_->trace_sync_io) return; + if (!trace_sync_io_) return; HandleScope handle_scope(isolate()); diff --git a/src/env.h b/src/env.h index 65173fd1cc8fc7..82ed066f9cde48 100644 --- a/src/env.h +++ b/src/env.h @@ -1250,6 +1250,7 @@ class Environment : public MemoryRetainer { const uint64_t timer_base_; std::shared_ptr env_vars_; bool printed_error_ = false; + bool trace_sync_io_ = false; bool emit_env_nonstring_warning_ = true; bool emit_err_name_warning_ = true; size_t async_callback_scope_depth_ = 0; diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 5d5a48cc36a54b..05ff8d55267511 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -111,6 +111,8 @@ int NodeMainInstance::Run() { env->async_hooks()->pop_async_id(1); } + env->set_trace_sync_io(env->options()->trace_sync_io); + { SealHandleScope seal(isolate_); bool more;