PR-URL: https://github.com/nodejs/node/pull/60641 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
22 lines
567 B
JavaScript
22 lines
567 B
JavaScript
'use strict';
|
|
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const async_hooks = require('async_hooks');
|
|
const { runInCallbackScope } = require(`./build/${common.buildType}/binding`);
|
|
|
|
let insideHook = false;
|
|
async_hooks.createHook({
|
|
before: common.mustCall((id) => {
|
|
assert.strictEqual(id, 1000);
|
|
insideHook = true;
|
|
}),
|
|
after: common.mustCall((id) => {
|
|
assert.strictEqual(id, 1000);
|
|
insideHook = false;
|
|
}),
|
|
}).enable();
|
|
|
|
runInCallbackScope({}, 1000, 1000, common.mustCallAtLeast(() => {
|
|
assert(insideHook);
|
|
}));
|