summaryrefslogtreecommitdiff
path: root/test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js
blob: 049264d3e8aef5bec7b72ff83e9b2027f67bc705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const common = require('../common');
const { Worker } = require('worker_threads');

// Like test-async-hooks-worker-promise.js but with the `await` and `createHook`
// lines switched, because that resulted in different assertion failures
// (one a Node.js assertion and one a V8 DCHECK) and it seems prudent to
// cover both of those failures.

const w = new Worker(`
const { createHook } = require('async_hooks');

setImmediate(async () => {
  await 0;
  createHook({ init() {} }).enable();
  process.exit();
});
`, { eval: true });

w.postMessage({});
w.on('exit', common.mustCall());