2016-11-22 13:13:44 -03:00
|
|
|
'use strict';
|
|
|
|
// Flags: --expose-gc
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2018-10-12 10:35:08 -07:00
|
|
|
const tick = require('../common/tick');
|
2016-11-22 13:13:44 -03:00
|
|
|
const initHooks = require('./init-hooks');
|
|
|
|
const { checkInvocations } = require('./hook-checks');
|
|
|
|
const dns = require('dns');
|
|
|
|
|
|
|
|
const hooks = initHooks();
|
|
|
|
|
|
|
|
hooks.enable();
|
2018-12-10 13:27:32 +01:00
|
|
|
// Uses cares for queryA which in turn uses QUERYWRAP
|
2016-11-22 13:13:44 -03:00
|
|
|
dns.resolve('localhost', common.mustCall(onresolved));
|
|
|
|
|
|
|
|
function onresolved() {
|
|
|
|
const as = hooks.activitiesOfTypes('QUERYWRAP');
|
|
|
|
const a = as[0];
|
2017-05-26 17:53:06 +02:00
|
|
|
assert.strictEqual(as.length, 1);
|
2016-11-22 13:13:44 -03:00
|
|
|
checkInvocations(a, { init: 1, before: 1 }, 'while in onresolved callback');
|
|
|
|
tick(1E4);
|
|
|
|
}
|
|
|
|
|
|
|
|
process.on('exit', onexit);
|
|
|
|
|
|
|
|
function onexit() {
|
|
|
|
hooks.disable();
|
|
|
|
hooks.sanityCheck('QUERYWRAP');
|
|
|
|
|
|
|
|
const as = hooks.activitiesOfTypes('QUERYWRAP');
|
2017-05-26 17:53:06 +02:00
|
|
|
assert.strictEqual(as.length, 1);
|
2016-11-22 13:13:44 -03:00
|
|
|
const a = as[0];
|
|
|
|
|
2017-05-26 17:53:06 +02:00
|
|
|
assert.strictEqual(a.type, 'QUERYWRAP');
|
|
|
|
assert.strictEqual(typeof a.uid, 'number');
|
2017-06-14 12:39:53 +02:00
|
|
|
assert.strictEqual(typeof a.triggerAsyncId, 'number');
|
2016-11-22 13:13:44 -03:00
|
|
|
checkInvocations(a, { init: 1, before: 1, after: 1, destroy: 1 },
|
|
|
|
'when process exits');
|
|
|
|
}
|