Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 05d1a53

Browse filesBrowse files
Trotttargos
authored andcommitted
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>
1 parent 3797625 commit 05d1a53
Copy full SHA for 05d1a53

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+3-4Lines changed: 3 additions & 4 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.