Skip to content

Commit 6675342

Browse files
jasnelltargos
authored andcommitted
doc: clarify that async_hook callbacks cannot be async
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #37384 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent d141fce commit 6675342

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/async_hooks.md

+4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ class MyAddedCallbacks extends MyAsyncCallbacks {
129129
const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
130130
```
131131

132+
Because promises are asynchronous resources whose lifecycle is tracked
133+
via the async hooks mechanism, the `init()`, `before()`, `after()`, and
134+
`destroy()` callbacks *must not* be async functions that return promises.
135+
132136
##### Error handling
133137

134138
If any `AsyncHook` callbacks throw, the application will print the stack trace

0 commit comments

Comments
 (0)