Skip to content

Commit 5634319

Browse files
TrottBethGriggs
authored andcommitted
test: remove try/catch in common.isMainThread
Refactor common.isMainThread. PR-URL: #25249 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 64847e3 commit 5634319

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/common/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ const noop = () => {};
4040
const hasCrypto = Boolean(process.versions.openssl);
4141

4242
const isMainThread = (() => {
43-
try {
43+
if (require('module').builtinModules.includes('worker_threads')) {
4444
return require('worker_threads').isMainThread;
45-
} catch {
46-
// Worker module not enabled → only a single main thread exists.
47-
return true;
4845
}
46+
// Worker module not enabled → only a single main thread exists.
47+
return true;
4948
})();
5049

5150
// Check for flags. Skip this for workers (both, the `cluster` module and

0 commit comments

Comments
 (0)