Skip to content

Commit

Permalink
doc: clarify that async_hook callbacks cannot be async
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jasnell authored and targos committed Feb 28, 2021
1 parent d141fce commit 6675342
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6675342

Please sign in to comment.