From 441b5453a0fd18db08d8391d7ae14e606a4ac57f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 17 Feb 2019 19:06:24 +0100 Subject: [PATCH] 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 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Beth Griggs --- test/parallel/test-worker-ref-onexit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-worker-ref-onexit.js b/test/parallel/test-worker-ref-onexit.js index 0250c592ce91ae..24c940f8c8df93 100644 --- a/test/parallel/test-worker-ref-onexit.js +++ b/test/parallel/test-worker-ref-onexit.js @@ -5,6 +5,8 @@ const { Worker } = require('worker_threads'); // Check that worker.unref() makes the 'exit' event not be emitted, if it is // 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.on('exit', common.mustNotCall());