From c1de6d249e9b17d53edc0a713c1e43ef9b457ea7 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Thu, 14 May 2015 11:46:54 -0600 Subject: core: implement runtime flag to trace sync io Use the --trace-sync-io flag to print a stack trace whenever a sync method is used after the first tick, excluding during the process exit event. (e.g. fs.readFileSync()) It does not track if the warning has occurred at a specific location in the past and so will print the warning every time. Reason for not printing during the first tick of the appication is so all necessary resources can be required. Also by excluding synchronous calls during exit is necessary in case any data needs to be logged out by the application before it shuts down. Fixes: https://github.com/nodejs/io.js/issues/1674 PR-URL: https://github.com/nodejs/io.js/pull/1707 Reviewed-By: Ben Noordhuis Reviewed-By: Fedor Indutny Reviewed-By: Jeremiah Senkpiel Reviewed-By: Petka Antonov --- src/env.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/env.h') diff --git a/src/env.h b/src/env.h index e327786e36b..b53ff87fb13 100644 --- a/src/env.h +++ b/src/env.h @@ -420,6 +420,9 @@ class Environment { inline bool printed_error() const; inline void set_printed_error(bool value); + void PrintSyncTrace() const; + inline void set_trace_sync_io(bool value); + inline void ThrowError(const char* errmsg); inline void ThrowTypeError(const char* errmsg); inline void ThrowRangeError(const char* errmsg); @@ -506,6 +509,7 @@ class Environment { bool using_abort_on_uncaught_exc_; bool using_asyncwrap_; bool printed_error_; + bool trace_sync_io_; debugger::Agent debugger_agent_; HandleWrapQueue handle_wrap_queue_; -- cgit v1.2.3