mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
4de31d517f
This error checking is mostly unnecessary and is just a Node core developer nicety, rather than something that is needed for the user-land. It can be safely removed without any practical impact while making nextTick, timers, immediates and AsyncResource substantially faster. PR-URL: https://github.com/nodejs/node/pull/30967 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
'use strict';
|
|
// Flags: --expose-internals
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const async_hooks = require('internal/async_hooks');
|
|
const initHooks = require('./init-hooks');
|
|
|
|
const expectedId = async_hooks.newAsyncId();
|
|
const expectedTriggerId = async_hooks.newAsyncId();
|
|
const expectedType = 'test_emit_init_type';
|
|
const expectedResource = { key: 'test_emit_init_resource' };
|
|
|
|
const hooks1 = initHooks({
|
|
oninit: common.mustCall((id, type, triggerAsyncId, resource) => {
|
|
assert.strictEqual(id, expectedId);
|
|
assert.strictEqual(type, expectedType);
|
|
assert.strictEqual(triggerAsyncId, expectedTriggerId);
|
|
assert.strictEqual(resource.key, expectedResource.key);
|
|
})
|
|
});
|
|
|
|
hooks1.enable();
|
|
|
|
async_hooks.emitInit(expectedId, expectedType, expectedTriggerId,
|
|
expectedResource);
|
|
|
|
hooks1.disable();
|
|
|
|
initHooks({
|
|
oninit: common.mustCall((id, type, triggerAsyncId, resource) => {
|
|
assert.strictEqual(id, expectedId);
|
|
assert.strictEqual(type, expectedType);
|
|
assert.notStrictEqual(triggerAsyncId, expectedTriggerId);
|
|
assert.strictEqual(resource.key, expectedResource.key);
|
|
})
|
|
}).enable();
|
|
|
|
async_hooks.emitInit(expectedId, expectedType, null, expectedResource);
|