mirror of
https://github.com/nodejs/node.git
synced 2025-05-22 00:43:56 +00:00

* Fix AsyncHooksGetTriggerAsyncId such it corresponds to async_hooks.triggerAsyncId and not async_hooks.initTriggerId. * Use an async_context struct instead of two async_uid values. This change was necessary since the fixing AsyncHooksGetTriggerAsyncId otherwise makes it impossible to get the correct default trigger id. It also prevents an invalid triggerAsyncId in MakeCallback. * Rename async_uid to async_id for consistency * Rename get_uid to get_async_id * Add get_trigger_async_id to AsyncResource class PR-URL: https://github.com/nodejs/node/pull/14040 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
27 lines
614 B
JavaScript
27 lines
614 B
JavaScript
'use strict';
|
|
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const binding = require(`./build/${common.buildType}/binding`);
|
|
const async_hooks = require('async_hooks');
|
|
|
|
assert.strictEqual(
|
|
binding.getExecutionAsyncId(),
|
|
async_hooks.executionAsyncId()
|
|
);
|
|
assert.strictEqual(
|
|
binding.getTriggerAsyncId(),
|
|
async_hooks.triggerAsyncId()
|
|
);
|
|
|
|
process.nextTick(common.mustCall(function() {
|
|
assert.strictEqual(
|
|
binding.getExecutionAsyncId(),
|
|
async_hooks.executionAsyncId()
|
|
);
|
|
assert.strictEqual(
|
|
binding.getTriggerAsyncId(),
|
|
async_hooks.triggerAsyncId()
|
|
);
|
|
}));
|