11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// Like test-async-hooks-worker-promise.js but doing a trivial counter increase
71cb0ef41Sopenharmony_ci// after process.exit(). This should not make a difference, but apparently it
81cb0ef41Sopenharmony_ci// does. This is *also* different from test-async-hooks-worker-promise-3.js,
91cb0ef41Sopenharmony_ci// in that the statement is an ArrayBuffer access rather than a full method,
101cb0ef41Sopenharmony_ci// which *also* makes a difference even though it shouldn’t.
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst workerData = new Int32Array(new SharedArrayBuffer(4));
131cb0ef41Sopenharmony_ciconst w = new Worker(`
141cb0ef41Sopenharmony_ciconst { createHook } = require('async_hooks');
151cb0ef41Sopenharmony_ciconst { workerData } = require('worker_threads');
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cisetImmediate(async () => {
181cb0ef41Sopenharmony_ci  createHook({ init() {} }).enable();
191cb0ef41Sopenharmony_ci  await 0;
201cb0ef41Sopenharmony_ci  process.exit();
211cb0ef41Sopenharmony_ci  workerData[0]++;
221cb0ef41Sopenharmony_ci});
231cb0ef41Sopenharmony_ci`, { eval: true, workerData });
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciw.on('exit', common.mustCall(() => assert.strictEqual(workerData[0], 0)));
26