You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/docs/api/promise.config.md
+22-1
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,28 @@ Cancellation is always configured separately per bluebird instance.
72
72
73
73
# Async hooks
74
74
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
+
constah=require('async_hooks');
80
+
constPromise=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
+
constah=require('async_hooks');
90
+
constPromise=require("bluebird");
91
+
Promise.config({asyncHooks:true});
92
+
Promise.resolve().then(() => {
93
+
console.log(`eid ${ah.executionAsyncId()} tid ${ah.triggerAsyncId()}`);
0 commit comments