1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const { Worker } = require('worker_threads'); 5 6// Like test-async-hooks-worker-promise.js but doing a trivial counter increase 7// after process.exit(). This should not make a difference, but apparently it 8// does. This is *also* different from test-async-hooks-worker-promise-3.js, 9// in that the statement is an ArrayBuffer access rather than a full method, 10// which *also* makes a difference even though it shouldn’t. 11 12const workerData = new Int32Array(new SharedArrayBuffer(4)); 13const w = new Worker(` 14const { createHook } = require('async_hooks'); 15const { workerData } = require('worker_threads'); 16 17setImmediate(async () => { 18 createHook({ init() {} }).enable(); 19 await 0; 20 process.exit(); 21 workerData[0]++; 22}); 23`, { eval: true, workerData }); 24 25w.on('exit', common.mustCall(() => assert.strictEqual(workerData[0], 0))); 26