Skip to content

Commit e2a801a

Browse files
antsmartiantargos
authored andcommitted
async_hooks: adding regression test case for async/await
The actual bug was fixed by a V8 update in Node v10.4.0. See: #19989 PR-URL: #22374 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f27a254 commit e2a801a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Test async-hooks fired on right
2+
// asyncIds & triggerAsyncId for async-await
3+
'use strict';
4+
5+
require('../common');
6+
const async_hooks = require('async_hooks');
7+
const assert = require('assert');
8+
9+
const asyncIds = [];
10+
async_hooks.createHook({
11+
init: (asyncId, type, triggerAsyncId) => {
12+
asyncIds.push([triggerAsyncId, asyncId]);
13+
}
14+
}).enable();
15+
16+
async function main() {
17+
await null;
18+
}
19+
20+
main().then(() => {
21+
// Verify the relationships between async ids
22+
// 1 => 2, 2 => 3 etc
23+
assert.strictEqual(asyncIds[0][1], asyncIds[1][0]);
24+
assert.strictEqual(asyncIds[0][1], asyncIds[3][0]);
25+
assert.strictEqual(asyncIds[1][1], asyncIds[2][0]);
26+
});

0 commit comments

Comments
 (0)