Skip to content

Commit

Permalink
test: remove try/catch in common.isMainThread
Browse files Browse the repository at this point in the history
Refactor common.isMainThread.

PR-URL: #25249
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Trott authored and targos committed Jan 1, 2019
1 parent 3797625 commit 05d1a53
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05d1a53

Please sign in to comment.