From 73e0b71f37193cd689ed3faf84f3c9d49a07eab7 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Tue, 4 Jan 2022 08:04:42 +0800 Subject: [PATCH] use isMainThread --- .../es-modules/tla/unresolved-with-worker-process-exit.mjs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/fixtures/es-modules/tla/unresolved-with-worker-process-exit.mjs b/test/fixtures/es-modules/tla/unresolved-with-worker-process-exit.mjs index 1860e95a73dd75..8d65baa2b59cce 100644 --- a/test/fixtures/es-modules/tla/unresolved-with-worker-process-exit.mjs +++ b/test/fixtures/es-modules/tla/unresolved-with-worker-process-exit.mjs @@ -1,8 +1,6 @@ -import { Worker } from 'worker_threads'; +import { Worker, isMainThread } from 'worker_threads'; -// Do not use isMainThread so that this test itself can be run inside a Worker. -if (!process.env.HAS_STARTED_WORKER) { - process.env.HAS_STARTED_WORKER = 1; +if (isMainThread) { new Worker(new URL(import.meta.url)); await new Promise(() => {}); } else {