From 6675342cd9f53a3a24a5b0db8290b716f1a5d010 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 c74c74d932fbb5..04b0929f91baae 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