node/test/parallel/test-async-hooks-enable-before-promise-resolve.js
Rich Trott 6059cbedbd
test: remove unnecessary noop function args to mustCall()
PR-URL: https://github.com/nodejs/node/pull/45027
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-10-18 12:13:41 +00:00

26 lines
688 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
// This test ensures that fast-path PromiseHook assigns async ids
// to already created promises when the native hook function is
// triggered on before event.
let initialAsyncId;
const promise = new Promise((resolve) => {
setTimeout(() => {
initialAsyncId = async_hooks.executionAsyncId();
async_hooks.createHook({
after: common.mustCall(2)
}).enable();
resolve();
}, 0);
});
promise.then(common.mustCall(() => {
const id = async_hooks.executionAsyncId();
assert.notStrictEqual(id, initialAsyncId);
assert.ok(id > 0);
}));