Skip to content
Permalink
Browse files

test: remove try/catch in common.isMainThread

Refactor common.isMainThread.

PR-URL: #25249
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
Trott authored and targos committed Dec 28, 2018
1 parent 3797625 commit 05d1a536cc1d91015edd2441edf766f459858a64
Showing with 3 additions and 4 deletions.
  1. +3 −4 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

0 comments on commit 05d1a53

Please sign in to comment.
You can’t perform that action at this time.