Skip to content

Commit c54bac1

Browse files
committedMay 25, 2019
update doc
1 parent 8120177 commit c54bac1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎docs/docs/api/promise.config.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,28 @@ Cancellation is always configured separately per bluebird instance.
7272

7373
# Async hooks
7474

75-
Bluebird supports [async hooks](https://nodejs.org/api/async_hooks.html) in node versions 9.6.0 and later. After it is enabled promises from the bluebird instance track async hook context.
75+
Bluebird supports [async hooks](https://nodejs.org/api/async_hooks.html) in node versions 9.6.0 and later. After it is enabled promises from the bluebird instance are assigned unique asyncIds:
76+
77+
```js
78+
// Async hooks disabled for bluebird
79+
const ah = require('async_hooks');
80+
const Promise = require("bluebird");
81+
Promise.resolve().then(() => {
82+
console.log(`eid ${ah.executionAsyncId()} tid ${ah.triggerAsyncId()}`);
83+
//
84+
});
85+
```
86+
87+
```js
88+
// Async hooks enabled for bluebird
89+
const ah = require('async_hooks');
90+
const Promise = require("bluebird");
91+
Promise.config({asyncHooks: true});
92+
Promise.resolve().then(() => {
93+
console.log(`eid ${ah.executionAsyncId()} tid ${ah.triggerAsyncId()}`);
94+
//
95+
});
96+
```
7697

7798
</markdown></div>
7899

0 commit comments

Comments
 (0)
Please sign in to comment.