From 3666ed62634c5bb5ee5befdbb0b8c073ddeccd22 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Mon, 18 Sep 2017 14:13:34 +0200 Subject: [PATCH] async_hooks: skip runtime checks when disabled Ref: https://github.com/nodejs/node/pull/14387 Ref: https://github.com/nodejs/node/pull/14722 Ref: https://github.com/nodejs/node/issues/14717 Ref: https://github.com/nodejs/node/issues/15448 --- doc/api/cli.md | 8 +++ doc/node.1 | 5 ++ lib/_http_outgoing.js | 10 ++- lib/async_hooks.js | 62 +++++++++---------- lib/internal/process/next_tick.js | 2 +- src/async-wrap.cc | 1 + src/env-inl.h | 23 +++++-- src/env.h | 3 + src/node.cc | 22 +++++-- test/async-hooks/test-emit-init.js | 57 ++++++++++------- test/async-hooks/test-force-checks-flag.js | 25 ++++++++ .../test-internal-nexttick-default-trigger.js | 5 -- .../test-no-assert-when-disabled.js | 26 ++++++++ test/common/index.js | 11 ++++ ...pector-async-hook-teardown-at-debug-end.js | 19 ++---- 15 files changed, 192 insertions(+), 87 deletions(-) create mode 100644 test/async-hooks/test-force-checks-flag.js create mode 100644 test/async-hooks/test-no-assert-when-disabled.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 4b2f78d94a55f1..b6d778f5ac484d 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -208,6 +208,14 @@ added: v2.1.0 Prints a stack trace whenever synchronous I/O is detected after the first turn of the event loop. +### `--force-async-hooks-checks` + + +Enables runtime checks for `async_hooks`. These can also be enabled dynamically +by enabling one of the `async_hooks` hooks. + ### `--trace-events-enabled`