Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: remove try/catch in common.isMainThread
Refactor common.isMainThread.
  • Loading branch information
Trott committed Dec 28, 2018
commit e78037b38e0a66b0604af88c8458c905bed3e240
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