1'use strict';
2const common = require('../common');
3const { Worker } = require('worker_threads');
4
5// This used to crash because the `.unref()` was unexpected while the Worker
6// was exiting.
7
8const w = new Worker(`
9require('worker_threads').parentPort.postMessage({});
10`, { eval: true });
11w.on('message', common.mustCall(() => {
12  w.unref();
13}));
14
15// Wait a bit so that the 'message' event is emitted while the Worker exits.
16Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
17