0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/async-hooks/test-graph.timeouts.js
Andreas Madsen de762b71f2
async_hooks: rename currentId and triggerId
currentId is renamed to executionAsyncId
triggerId is renamed to triggerAsyncId
AsyncResource.triggerId is renamed to AsyncResource.triggerAsyncId
AsyncHooksGetCurrentId is renamed to AsyncHooksGetExecutionAsyncId
AsyncHooksGetTriggerId is renamed to AsyncHooksGetTriggerAsyncId

PR-URL: https://github.com/nodejs/node/pull/13490
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2017-06-14 12:39:53 +02:00

36 lines
956 B
JavaScript

'use strict';
const common = require('../common');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const TIMEOUT = 1;
const hooks = initHooks();
hooks.enable();
setTimeout(common.mustCall(ontimeout), TIMEOUT);
function ontimeout() {
setTimeout(onsecondTimeout, TIMEOUT + 1);
}
function onsecondTimeout() {
setTimeout(onthirdTimeout, TIMEOUT + 2);
}
function onthirdTimeout() {}
process.on('exit', onexit);
function onexit() {
hooks.disable();
verifyGraph(
hooks,
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
{ type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: null },
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' },
{ type: 'TIMERWRAP', id: 'timer:2', triggerAsyncId: 'timeout:1' },
{ type: 'Timeout', id: 'timeout:3', triggerAsyncId: 'timeout:2' },
{ type: 'TIMERWRAP', id: 'timer:3', triggerAsyncId: 'timeout:2' } ]
);
}