• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Test async-hooks fired on right
2// asyncIds & triggerAsyncId for async-await
3'use strict';
4
5require('../common');
6const async_hooks = require('async_hooks');
7const assert = require('assert');
8
9const asyncIds = [];
10async_hooks.createHook({
11  init: (asyncId, type, triggerAsyncId) => {
12    asyncIds.push([triggerAsyncId, asyncId]);
13  }
14}).enable();
15
16async function main() {
17  await null;
18}
19
20main().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});
27