diff --git a/test/common/index.js b/test/common/index.js index 142957151ac727..24b5c73e9f4b1a 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -39,12 +39,11 @@ const noop = () => {}; const hasCrypto = Boolean(process.versions.openssl); const isMainThread = (() => { - try { + if (require('module').builtinModules.includes('worker_threads')) { return require('worker_threads').isMainThread; - } catch { - // Worker module not enabled → only a single main thread exists. - return true; } + // Worker module not enabled → only a single main thread exists. + return true; })(); // Check for flags. Skip this for workers (both, the `cluster` module and