Skip to content

Commit 05d1a53

Browse files
Trotttargos
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 3797625 commit 05d1a53

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
@@ -39,12 +39,11 @@ const noop = () => {};
3939
const hasCrypto = Boolean(process.versions.openssl);
4040

4141
const isMainThread = (() => {
42-
try {
42+
if (require('module').builtinModules.includes('worker_threads')) {
4343
return require('worker_threads').isMainThread;
44-
} catch {
45-
// Worker module not enabled → only a single main thread exists.
46-
return true;
4744
}
45+
// Worker module not enabled → only a single main thread exists.
46+
return true;
4847
})();
4948

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

0 commit comments

Comments
 (0)