test: fix flaky test-worker-ref-onexit

Fixes: https://github.com/nodejs/node/issues/26167

PR-URL: https://github.com/nodejs/node/pull/26170
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
This commit is contained in:
Anna Henningsen 2019-02-17 19:06:24 +01:00
parent 1d51353665
commit 2da7ff5e96
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -5,6 +5,8 @@ const { Worker } = require('worker_threads');
// Check that worker.unref() makes the 'exit' event not be emitted, if it is // Check that worker.unref() makes the 'exit' event not be emitted, if it is
// the only thing we would otherwise be waiting for. // the only thing we would otherwise be waiting for.
const w = new Worker('', { eval: true }); // Use `setInterval()` to make sure the worker is alive until the end of the
// event loop turn.
const w = new Worker('setInterval(() => {}, 100);', { eval: true });
w.unref(); w.unref();
w.on('exit', common.mustNotCall()); w.on('exit', common.mustNotCall());