• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4const assert = require('assert');
5const async_hooks = require('async_hooks');
6const initHooks = require('./init-hooks');
7const { checkInvocations } = require('./hook-checks');
8
9const hooks = initHooks();
10hooks.enable();
11
12const rootAsyncId = async_hooks.executionAsyncId();
13
14queueMicrotask(common.mustCall(() => {
15  assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
16}));
17
18process.on('exit', () => {
19  hooks.sanityCheck();
20
21  const as = hooks.activitiesOfTypes('Microtask');
22  checkInvocations(as[0], {
23    init: 1, before: 1, after: 1, destroy: 1
24  }, 'when process exits');
25});
26