• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Regression test for https://github.com/nodejs/node/issues/13262
4
5const common = require('../common');
6const assert = require('assert');
7const async_hooks = require('async_hooks');
8
9if (!common.isMainThread)
10  common.skip('Worker bootstrapping works differently -> different async IDs');
11
12let seenId, seenResource;
13
14async_hooks.createHook({
15  init: common.mustCall((id, provider, triggerAsyncId, resource) => {
16    seenId = id;
17    seenResource = resource;
18    assert.strictEqual(provider, 'Immediate');
19    assert.strictEqual(triggerAsyncId, 1);
20  }),
21  before: common.mustNotCall(),
22  after: common.mustNotCall(),
23  destroy: common.mustCall((id) => {
24    assert.strictEqual(seenId, id);
25  })
26}).enable();
27
28const immediate = setImmediate(common.mustNotCall());
29assert.strictEqual(immediate, seenResource);
30clearImmediate(immediate);
31