11'use strict' ;
22
3- process . on ( 'uncaughtException' , ( err ) => {
4- process . _rawDebug ( 'process uncaughtException:' , new Error ( ) . stack ) ;
5- const { triggerUncaughtException } = internalBinding ( 'errors' ) ;
6- releaseLock ( ) ;
7- triggerUncaughtException ( err ) ;
8- } ) ;
9-
103const {
114 Int32Array,
125 ReflectApply,
@@ -49,7 +42,6 @@ function releaseLock() {
4942 try {
5043 initializeESM ( ) ;
5144 hooks = await initializeHooks ( ) ;
52- process . _rawDebug ( '[WORKER]:' , 'hooks:' , hooks ) ;
5345 } catch ( exception ) {
5446 // If there was an error while parsing and executing a user loader, for example if because a loader contained a syntax error,
5547 // then we need to send the error to the main thread so it can be thrown and printed.
@@ -65,7 +57,6 @@ process._rawDebug('[WORKER]:', 'hooks:', hooks);
6557 Atomics . wait ( lock , 0 , 1 ) ; // This pauses the while loop
6658
6759 const { method, args } = deserialize ( data ) ;
68- process . _rawDebug ( '[WORKER]:' , 'request received:' , method , args ) ;
6960 TypedArrayPrototypeFill ( data , undefined ) ;
7061
7162 // Each potential exception needs to be caught individually so that the correct error is sent to the main thread
@@ -85,26 +76,19 @@ process._rawDebug('[WORKER]:', 'hooks:', hooks);
8576 }
8677
8778 try {
88- process . _rawDebug ( '[WORKER]:' , 'response:' , response ) ;
8979 const serializedResponseValue = serialize ( response ) ;
9080 const chunkCount = Math . ceil ( serializedResponseValue . byteLength / CHUNK_THRESHOLD ) ;
91- process . _rawDebug ( '[WORKER]:' , 'chunkCount:' , chunkCount )
9281 for ( let i = 0 ; i < chunkCount ; i ++ ) {
9382 const chunk = {
9483 __proto__ : null ,
9584 done : i === chunkCount - 1 ,
9685 value : serializedResponseValue . slice ( i ) ,
9786 } ;
98- process . _rawDebug ( '[WORKER]:' , 'chunk:' , chunk ) ;
9987 const serializedChunk = serialize ( chunk ) ;
100- process . _rawDebug ( '[WORKER]:' , 'serializedChunk:' , serializedChunk ) ;
10188 // Send the method response (or exception) to the main thread
102-
10389 TypedArrayPrototypeSet ( data , serializedChunk ) ;
104- // process._rawDebug('[WORKER]:', 'chunk set; releasing lock');
10590 releaseLock ( ) ;
10691 }
107-
10892 } catch ( exception ) {
10993 TypedArrayPrototypeSet ( data , serialize ( exception ) ) ;
11094 releaseLock ( ) ;
@@ -118,3 +102,10 @@ process._rawDebug('[WORKER]:', 'hooks:', hooks);
118102 releaseLock ( ) ;
119103 triggerUncaughtException ( err ) ;
120104} ) ;
105+
106+ process . on ( 'uncaughtException' , ( err ) => {
107+ process . _rawDebug ( 'process uncaughtException:' , new Error ( ) . stack ) ;
108+ const { triggerUncaughtException } = internalBinding ( 'errors' ) ;
109+ releaseLock ( ) ;
110+ triggerUncaughtException ( err ) ;
111+ } ) ;
0 commit comments