Skip to content

Commit 2a08b93

Browse files
authored
Merge pull request #269 from addaleax/fix-workers
Fix Node.js Worker support by not shimming uncaughtException
2 parents 61ebf23 + 59b442f commit 2a08b93

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source-map-support.js

+12
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,18 @@ exports.install = function(options) {
561561
var installHandler = 'handleUncaughtExceptions' in options ?
562562
options.handleUncaughtExceptions : true;
563563

564+
// Do not override 'uncaughtException' with our own handler in Node.js
565+
// Worker threads. Workers pass the error to the main thread as an event,
566+
// rather than printing something to stderr and exiting.
567+
try {
568+
// Don't let browserify try to resolve this require(), it's pointless
569+
// and breaks the build process.
570+
var worker_threads = require('worker_' + 'threads');
571+
if (worker_threads.isMainThread === false) {
572+
installHandler = false;
573+
}
574+
} catch(e) {}
575+
564576
// Provide the option to not install the uncaught exception handler. This is
565577
// to support other uncaught exception handlers (in test frameworks, for
566578
// example). If this handler is not installed and there are no other uncaught

0 commit comments

Comments
 (0)