diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index a37ac871cfdaf6..44fb42cd9530d1 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -498,12 +498,9 @@ class HooksProxy { } TypedArrayPrototypeFill(this.#data, undefined); // Erase handled request/response data -// console.log('sending request', method, args) const request = serialize({ method, args }); TypedArrayPrototypeSet(this.#data, request); - // this.#awaitResponse(); - const chunks = []; let done = false; try { @@ -511,20 +508,11 @@ class HooksProxy { this.#awaitResponse(); const chunk = deserialize(this.#data); - console.log('chunk:', chunk) - if (chunk instanceof Error) { throw chunk; } - ({ done } = chunk); chunks.push(chunk.value); - - console.log('awaiting next') } } catch (exception) { - console.log('\nmakeRequest failed!\n'); - console.log(this.#data); - console.log('byteLength:', this.#data.byteLength); - console.log('this.#data[0]:', this.#data[0]); if (this.#data[0] === 0) { // Response should not be empty throw new ERR_INVALID_RETURN_VALUE('an object', method, undefined); } else { @@ -533,9 +521,6 @@ class HooksProxy { } const response = Buffer.concat(chunks); - - console.log('[HooksProxy]::makeRequest() finished:', deserialize(response)); - return response; } diff --git a/lib/internal/modules/esm/worker.js b/lib/internal/modules/esm/worker.js index 77a7e44e932e21..4c1796661e9111 100644 --- a/lib/internal/modules/esm/worker.js +++ b/lib/internal/modules/esm/worker.js @@ -1,12 +1,5 @@ 'use strict'; -process.on('uncaughtException', (err) => { - process._rawDebug('process uncaughtException:', new Error().stack); - const { triggerUncaughtException } = internalBinding('errors'); - releaseLock(); - triggerUncaughtException(err); -}); - const { Int32Array, ReflectApply, @@ -49,7 +42,6 @@ function releaseLock() { try { initializeESM(); hooks = await initializeHooks(); -process._rawDebug('[WORKER]:', 'hooks:', hooks); } catch (exception) { // If there was an error while parsing and executing a user loader, for example if because a loader contained a syntax error, // 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); Atomics.wait(lock, 0, 1); // This pauses the while loop const { method, args } = deserialize(data); - process._rawDebug('[WORKER]:', 'request received:', method, args); TypedArrayPrototypeFill(data, undefined); // 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); } try { - process._rawDebug('[WORKER]:', 'response:', response); const serializedResponseValue = serialize(response); const chunkCount = Math.ceil(serializedResponseValue.byteLength / CHUNK_THRESHOLD); - process._rawDebug('[WORKER]:', 'chunkCount:', chunkCount) for (let i = 0; i < chunkCount; i++) { const chunk = { __proto__: null, done: i === chunkCount - 1, value: serializedResponseValue.slice(i), }; - process._rawDebug('[WORKER]:', 'chunk:', chunk); const serializedChunk = serialize(chunk); - process._rawDebug('[WORKER]:', 'serializedChunk:', serializedChunk); // Send the method response (or exception) to the main thread - TypedArrayPrototypeSet(data, serializedChunk); - // process._rawDebug('[WORKER]:', 'chunk set; releasing lock'); releaseLock(); } - } catch (exception) { TypedArrayPrototypeSet(data, serialize(exception)); releaseLock(); @@ -118,3 +102,10 @@ process._rawDebug('[WORKER]:', 'hooks:', hooks); releaseLock(); triggerUncaughtException(err); }); + +process.on('uncaughtException', (err) => { + process._rawDebug('process uncaughtException:', new Error().stack); + const { triggerUncaughtException } = internalBinding('errors'); + releaseLock(); + triggerUncaughtException(err); +});