From c8a27a761773b9815bd6af07ce6d6e72ae19df30 Mon Sep 17 00:00:00 2001 From: Anto Aravinth Date: Wed, 22 Aug 2018 17:16:08 +0530 Subject: [PATCH] async_hooks: adding regression test case for async/await The actual bug was fixed by a V8 update in Node v10.4.0. See: https://github.com/nodejs/node/pull/19989 PR-URL: https://github.com/nodejs/node/pull/22374 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- test/parallel/test-async-hooks-async-await.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/parallel/test-async-hooks-async-await.js diff --git a/test/parallel/test-async-hooks-async-await.js b/test/parallel/test-async-hooks-async-await.js new file mode 100644 index 00000000000000..791adab75c8621 --- /dev/null +++ b/test/parallel/test-async-hooks-async-await.js @@ -0,0 +1,26 @@ +// Test async-hooks fired on right +// asyncIds & triggerAsyncId for async-await +'use strict'; + +require('../common'); +const async_hooks = require('async_hooks'); +const assert = require('assert'); + +const asyncIds = []; +async_hooks.createHook({ + init: (asyncId, type, triggerAsyncId) => { + asyncIds.push([triggerAsyncId, asyncId]); + } +}).enable(); + +async function main() { + await null; +} + +main().then(() => { + // Verify the relationships between async ids + // 1 => 2, 2 => 3 etc + assert.strictEqual(asyncIds[0][1], asyncIds[1][0]); + assert.strictEqual(asyncIds[0][1], asyncIds[3][0]); + assert.strictEqual(asyncIds[1][1], asyncIds[2][0]); +});