nodejs/test/parallel/test-async-wrap-trigger-id.js

29 lines
768 B
JavaScript
Raw Normal View History

'use strict';
require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const triggerAsyncId = async_hooks.triggerAsyncId;
const triggerAsyncId0 = triggerAsyncId();
let triggerAsyncId1;
process.nextTick(() => {
process.nextTick(() => {
triggerAsyncId1 = triggerAsyncId();
assert.notStrictEqual(
triggerAsyncId0,
triggerAsyncId1,
'Async resources having different causal ancestry ' +
'should have different triggerAsyncIds');
});
process.nextTick(() => {
const triggerAsyncId2 = triggerAsyncId();
assert.strictEqual(
triggerAsyncId1,
triggerAsyncId2,
'Async resources having the same causal ancestry ' +
'should have the same triggerAsyncId');
});
});