Skip to content

Commit 3a3fea0

Browse files
authored
Remove try/catch when importing node's worker_threads (#21045)
This seems like excessive error checking. Node has supported `worker_threads` going back v15 and the error folks will when this module is missing should be pretty clear/actionable without us adding this extra info. Also remove unneeded local variable.
1 parent 90696df commit 3a3fea0

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src/shell.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,7 @@ if (ENVIRONMENT_IS_NODE) {
265265
Module['inspect'] = () => '[Emscripten Module object]';
266266

267267
#if PTHREADS || WASM_WORKERS
268-
let nodeWorkerThreads;
269-
try {
270-
nodeWorkerThreads = require('worker_threads');
271-
} catch (e) {
272-
console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?');
273-
throw e;
274-
}
275-
global.Worker = nodeWorkerThreads.Worker;
268+
global.Worker = require('worker_threads').Worker;
276269
#endif
277270

278271
#if WASM == 2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5031
1+
4949
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13863
1+
13710

0 commit comments

Comments
 (0)