Skip to content

Commit 93acd77

Browse files
committed
Remove console log
1 parent 1582650 commit 93acd77

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

src/DenoHTTPWorker.test.ts

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
6767
onSpawn: (process) => {
6868
pid = process.pid;
6969
},
70-
printOutput: true,
7170
}
7271
);
7372
expect(pid).toBeDefined();
@@ -105,7 +104,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
105104
return Response.json({ ok: req.url })
106105
} }
107106
`,
108-
{ printOutput: true }
107+
{ printOutput: false }
109108
);
110109
const json = await jsonRequest(worker, "https://localhost/hello?isee=you", {
111110
headers: { accept: "application/json" },
@@ -127,7 +126,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
127126
return Response.json({ ok: req.url, headers: headers })
128127
} }
129128
`,
130-
{ printOutput: true }
129+
{ printOutput: false }
131130
);
132131
for (let i = 0; i < 10; i++) {
133132
const json = await jsonRequest(
@@ -152,7 +151,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
152151
return Response.json({ error: error.message }, { status: 500 })
153152
}}
154153
`,
155-
{ printOutput: true }
154+
{ printOutput: false }
156155
);
157156
const json = await jsonRequest(worker, "https://localhost/hello?isee=you", {
158157
headers: { accept: "application/json" },
@@ -228,7 +227,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
228227
return Response.json({ ok: req.url })
229228
}}
230229
`,
231-
{ printOutput: true }
230+
{ printOutput: false }
232231
);
233232

234233
let logs = "";
@@ -243,11 +242,9 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
243242
});
244243
});
245244
const json = await jsonRequest(worker, "https://localhost/hello?isee=you");
246-
console.log(json);
247245
expect(json).toEqual({
248246
ok: "https://localhost/hello?isee=you",
249247
});
250-
console.log("OKK");
251248
void worker.shutdown();
252249
await exitPromise;
253250
});
@@ -262,7 +259,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
262259
"--allow-write=bar,/dev/null",
263260
])("should handle %s", async (flag) => {
264261
const worker = await newDenoHTTPWorker(echoScript, {
265-
printOutput: true,
262+
printOutput: false,
266263
runFlags: [flag],
267264
});
268265
await jsonRequest(worker, "http://localhost");
@@ -274,8 +271,8 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
274271
const file = path.resolve(__dirname, "./test/echo-request.ts");
275272
const url = new URL(`file://${file}`);
276273
const worker = await newDenoHTTPWorker(url, {
277-
printOutput: true,
278-
printCommandAndArguments: true,
274+
printOutput: false,
275+
printCommandAndArguments: false,
279276
});
280277

281278
await jsonRequest(worker, "http://localhost");
@@ -284,7 +281,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
284281

285282
it("host and connection is not overwritten", async () => {
286283
const worker = await newDenoHTTPWorker(echoScript, {
287-
printOutput: true,
284+
printOutput: false,
288285
});
289286
const resp: any = await jsonRequest(worker, "https://localhost/", {
290287
headers: {
@@ -317,14 +314,12 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
317314

318315
await new Promise((resolve) => setTimeout(resolve, 300));
319316

320-
const t0 = performance.now();
321317
const resp = await worker.request({
322318
url: "http://localhost/hi",
323319
method: "GET",
324320
});
325321
const json = await resp.body.json();
326322

327-
console.log("http request time", performance.now() - t0);
328323
expect(json).toEqual({
329324
url: "http://localhost/hi",
330325
headers: {},
@@ -337,7 +332,6 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
337332
it("can implement val town with http.request", async () => {
338333
const worker = await newDenoHTTPWorker(vtScript, { printOutput: true });
339334

340-
const t0 = performance.now();
341335
await worker.request({
342336
url: "http://vt/",
343337
method: "POST",
@@ -355,31 +349,10 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
355349
.then((resp) => resp.body.text());
356350

357351
expect(text).toEqual('{"ok":true}');
358-
console.log("Double request http2 val:", performance.now() - t0);
359352
// await initReq;
360353
await worker.terminate();
361354
});
362355

363-
// it("val town import header", async () => {
364-
// const worker = await newDenoHTTPWorker(vtHeaderScript, { printOutput: true });
365-
366-
// const t0 = performance.now();
367-
// const text = await worker.request({
368-
// url: "https://localhost:1234",
369-
// path: "/",
370-
// headers: {
371-
// "X-VT-Import": `data:text/tsx,${encodeURIComponent(
372-
// DEFAULT_HTTP_VAL
373-
// )}`,
374-
// },
375-
// }).then(resp => resp.body.text())
376-
377-
// expect(text).toEqual('{"ok":true}');
378-
// console.log("single request:", performance.now() - t0);
379-
// // await initReq;
380-
// worker.terminate();
381-
// });
382-
383356
it("can test that snippets in readme run successfully", async () => {
384357
const rm = fs.readFileSync(path.resolve(__dirname, "../README.md"), {
385358
encoding: "utf-8",
@@ -391,7 +364,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
391364
.map((line) => line.slice(3));
392365
for (let source of toTest) {
393366
source = source.replaceAll(
394-
"import { newDenoHTTPWorker } from 'deno-http-worker';",
367+
'import { newDenoHTTPWorker } from "deno-http-worker";',
395368
"const { newDenoHTTPWorker } = await import('./dist/index.js'); "
396369
);
397370
source = `(async () => {${source}})()`;
@@ -400,18 +373,16 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
400373
const worker = new Worker(source, {
401374
eval: true,
402375
});
403-
worker.stderr.on("data", (data) => {
404-
console.error(data.toString());
376+
worker.stderr.on("data", (_data) => {
377+
// console.error(data.toString());
405378
});
406-
worker.stdout.on("data", (data) => {
407-
console.error(data.toString());
379+
worker.stdout.on("data", (_data) => {
380+
// console.error(data.toString());
408381
});
409382
worker.on("error", (e) => {
410-
console.log(e.stack);
411383
reject(e);
412384
});
413-
worker.on("exit", (code) => {
414-
console.log(code);
385+
worker.on("exit", (_code) => {
415386
resolve();
416387
});
417388
});
@@ -423,14 +394,13 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
423394
encoding: "utf-8",
424395
});
425396
const worker = await newDenoHTTPWorker(webSocketScriptStr, {
426-
printOutput: true,
397+
printOutput: false,
427398
});
428399

429400
const messages: string[] = [];
430401
const ws = await worker.websocket("ws://localhost/echo");
431402
const event = await new Promise<Event>((res) => {
432403
ws.addEventListener("open", (event) => {
433-
console.log("WebSocket connection opened");
434404
ws.send("message1");
435405
res(event);
436406
});
@@ -463,7 +433,7 @@ describe("DenoHTTPWorker", { timeout: 1000 }, () => {
463433
encoding: "utf-8",
464434
});
465435
const worker = await newDenoHTTPWorker(webSocketScriptStr, {
466-
printOutput: true,
436+
printOutput: false,
467437
});
468438

469439
const ws1 = await worker.websocket("ws://localhost/echo");

src/DenoHTTPWorker.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ class denoHTTPWorker implements DenoHTTPWorker {
344344
}
345345

346346
async shutdown() {
347-
console.log("Shutting down Deno worker...");
348347
this.#process.kill("SIGINT");
349348
await new Promise<void>((res) => {
350349
this.#process.on("exit", res);
@@ -367,7 +366,6 @@ class denoHTTPWorker implements DenoHTTPWorker {
367366
url: string,
368367
headers: Headers = new Headers()
369368
): Promise<WebSocket> {
370-
console.log("Opening WebSocket connection to:", url);
371369
headers = this.#processHeaders(headers, url);
372370
headers.set("x-deno-worker-connection", "upgrade"); // Required for websockets
373371

0 commit comments

Comments
 (0)