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 <[email protected]>

PR-URL: #37384
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
  • Loading branch information
jasnell authored and targos committed May 1, 2021
1 parent 512ae7e commit 4785755
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 4785755

Please sign in to comment.