From 478575501438c0b211d0df32108ab5af4c11bafa Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 15 Feb 2021 07:34:23 -0800 Subject: [PATCH] doc: clarify that async_hook callbacks cannot be async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/37384 Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Darshan Sen Reviewed-By: Zijian Liu Reviewed-By: Gerhard Stöbich --- doc/api/async_hooks.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 1a8debe8451d0b..0384f22ad5097d 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -129,6 +129,10 @@ class MyAddedCallbacks extends MyAsyncCallbacks { const asyncHook = async_hooks.createHook(new MyAddedCallbacks()); ``` +Because promises are asynchronous resources whose lifecycle is tracked +via the async hooks mechanism, the `init()`, `before()`, `after()`, and +`destroy()` callbacks *must not* be async functions that return promises. + ##### Error handling If any `AsyncHook` callbacks throw, the application will print the stack trace