Skip to content

Commit 7578911

Browse files
JakobJingleheimerGeoffreyBooth
authored andcommitted
remove writeFileSync debugging
1 parent 7ae2100 commit 7578911

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

lib/internal/modules/esm/hooks.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const {
6666
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
6767
debug = fn;
6868
});
69-
const { writeFileSync } = require('fs');
7069

7170

7271
let importMetaInitializer;
@@ -128,16 +127,12 @@ class Hooks {
128127
*/
129128
async register(urlOrSpecifier, parentURL, data) {
130129
const moduleLoader = require('internal/process/esm_loader').esmLoader;
131-
// debug('Hooks::register', { urlOrSpecifier, parentURL, data }, moduleLoader.import)
132130
const keyedExports = await moduleLoader.import(
133131
urlOrSpecifier,
134132
parentURL,
135133
kEmptyObject,
136-
).catch((err) => {
137-
writeFileSync(1, `Hooks::register err ${err.stack}\n`);
138-
throw err;
139-
});
140-
debug('Hooks::register imported', urlOrSpecifier, keyedExports)
134+
);
135+
141136
return this.addCustomLoader(urlOrSpecifier, keyedExports, data);
142137
}
143138

@@ -590,10 +585,8 @@ class HooksProxy {
590585
AtomicsWait(this.#lock, WORKER_TO_MAIN_THREAD_NOTIFICATION, this.#workerNotificationLastId);
591586
this.#workerNotificationLastId = AtomicsLoad(this.#lock, WORKER_TO_MAIN_THREAD_NOTIFICATION);
592587

593-
writeFileSync(1, `HooksProxy::makeSyncRequest: awoken\n`);
594588
response = this.#worker.receiveMessageSync();
595589
} while (response == null);
596-
writeFileSync(1, `HooksProxy::makeSyncRequest: got response from worker ${JSON.stringify(response)}\n`);
597590
debug('got sync response from worker', { method, args });
598591
if (response.message.status === 'never-settle') {
599592
process.exit(kUnfinishedTopLevelAwait);
@@ -609,7 +602,6 @@ class HooksProxy {
609602
}
610603
const { status, body } = response.message;
611604
if (status === 'error') {
612-
writeFileSync(1, `HooksProxy#unwrapMessage: got error from worker ${body}\n`);
613605
if (body == null || typeof body !== 'object') throw body;
614606
if (body.serializationFailed || body.serialized == null) {
615607
throw ERR_WORKER_UNSERIALIZABLE_ERROR();

lib/internal/modules/esm/loader.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let defaultResolve, defaultLoad, defaultLoadSync, importMetaInitializer;
2323
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
2424
debug = fn;
2525
});
26-
const { writeFileSync } = require('fs');
26+
2727

2828
function newResolveCache() {
2929
const { ResolveCache } = require('internal/modules/esm/module_map');
@@ -309,16 +309,9 @@ class ModuleLoader {
309309
* @returns {Promise<ModuleExports>}
310310
*/
311311
async import(specifier, parentURL, importAssertions) {
312-
// writeFileSync(1, `ESMLoader::import specifier ${specifier}\n`);
313312
const moduleJob = await this.getModuleJob(specifier, parentURL, importAssertions);
314-
// writeFileSync(1, `ESMLoader::import gotModuleJob ${JSON.stringify(moduleJob)}\n`);
315-
const { module } = await moduleJob.run().catch((err) => {
316-
writeFileSync(1, `ESMLoader::import ${specifier} moduleJob.run caught error ${err.stack}\n`)
317-
throw err;
318-
});
319-
writeFileSync(1, `ESMLoader::import ${specifier} gotModuleJob ${JSON.stringify(module)}\n`);
313+
const { module } = await moduleJob.run();
320314
const namespace = module.getNamespace();
321-
writeFileSync(1, `ESMLoader::import ${specifier} gotModuleJob ${JSON.stringify(namespace)}\n`);
322315
return namespace;
323316
}
324317

lib/internal/modules/esm/module_job.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const resolvedPromise = PromiseResolve();
3030
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
3131
debug = fn;
3232
});
33-
// const { writeFileSync } = require('fs');
3433

3534
const noop = FunctionPrototype;
3635

@@ -114,21 +113,20 @@ class ModuleJob {
114113
}
115114

116115
async _instantiate() {
117-
// writeFileSync(1, 'ModuleJob::instantiate()\n');
118116
const jobsInGraph = new SafeSet();
119117
const addJobsToDependencyGraph = async (moduleJob) => {
120118
if (jobsInGraph.has(moduleJob)) {
121119
return;
122120
}
123121
jobsInGraph.add(moduleJob);
124-
// writeFileSync(1, 'ModuleJob::instantiate() getting linked jobs\n');
122+
125123
const dependencyJobs = await moduleJob.linked;
126-
// writeFileSync(1, 'ModuleJob::instantiate() got linked jobs\n');
124+
127125
return SafePromiseAllReturnVoid(dependencyJobs, addJobsToDependencyGraph);
128126
};
127+
129128
await addJobsToDependencyGraph(this);
130129

131-
// writeFileSync(1, 'ModuleJob::instantiate() job added to dep graph\n');
132130
try {
133131
if (!hasPausedEntry && this.inspectBrk) {
134132
hasPausedEntry = true;
@@ -138,7 +136,7 @@ class ModuleJob {
138136
this.module.instantiate();
139137
}
140138
} catch (e) {
141-
// writeFileSync(1, `ModuleJob::instantiate() error: ${e.stack}\n`);
139+
142140
decorateErrorStack(e);
143141
// TODO(@bcoe): Add source map support to exception that occurs as result
144142
// of missing named export. This is currently not possible because
@@ -218,16 +216,14 @@ class ModuleJob {
218216
}
219217

220218
async run() {
221-
// writeFileSync(1, `ModuleJob::run() instantiating: ${this.url}\n`);
222219
await this.instantiate();
223-
// writeFileSync(1, `ModuleJob::run() instantiated: ${this.url}\n`);
224220
const timeout = -1;
225221
const breakOnSigint = false;
222+
226223
try {
227224
await this.module.evaluate(timeout, breakOnSigint);
228-
// writeFileSync(1, `ModuleJob::run() evaluation complete: ${this.module}\n`);
225+
229226
} catch (e) {
230-
// writeFileSync(1, `ModuleJob::run() error: ${e.stack}\n`);
231227
if (e?.name === 'ReferenceError' &&
232228
isCommonJSGlobalLikeNotDefinedError(e.message)) {
233229
e.message += ' in ES module scope';
@@ -249,7 +245,7 @@ class ModuleJob {
249245
'to use the \'.cjs\' file extension.';
250246
}
251247
}
252-
// writeFileSync(1, `ModuleJob::run() throwing error: ${e.stack}\n`);
248+
253249
throw e;
254250
}
255251
return { __proto__: null, module: this.module };

lib/internal/modules/esm/utils.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const assert = require('internal/assert');
2828
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
2929
debug = fn;
3030
});
31-
const { writeFileSync } = require('fs');
31+
3232

3333
const callbackMap = new SafeWeakMap();
3434
function setCallbackForWrap(wrap, data) {
@@ -152,10 +152,7 @@ async function initializeHooks() {
152152
await hooks.register(
153153
customLoaderURLs[i],
154154
parentURL,
155-
).catch((err) => {
156-
writeFileSync(1, `initializeHooks: Error registering hooks: ${err.stack}\n`);
157-
throw err;
158-
});
155+
);
159156
}
160157
debug('initializeHooks finished: hooks', hooks);
161158

lib/internal/modules/esm/worker.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const {
3131
} = require('internal/modules/esm/shared_constants');
3232
const { initializeHooks } = require('internal/modules/esm/utils');
3333
const { isMarkedAsUntransferable } = require('internal/buffer');
34-
const { writeFileSync } = require('fs');
3534

3635

3736
function transferArrayBuffer(hasError, source) {
@@ -101,13 +100,11 @@ async function customizedModuleWorker(lock, syncCommPort, errorHandler) {
101100
// be thrown and printed.
102101
hasInitializationError = true;
103102
initializationError = exception;
104-
writeFileSync(1, `[Worker] Error initializing hooks: ${exception.stack}\n`);
105103
}
106104

107105
syncCommPort.on('message', handleMessage);
108106

109107
if (hasInitializationError) {
110-
writeFileSync(1, `[Worker] posting initialization error: ${initializationError}\n`);
111108
syncCommPort.postMessage(wrapMessage('error', initializationError));
112109
} else {
113110
syncCommPort.postMessage(wrapMessage('success'));

0 commit comments

Comments
 (0)