Skip to content

Commit 2233e77

Browse files
committed
chore(runner): disable default logs
1 parent 4c04b26 commit 2233e77

File tree

1 file changed

+65
-67
lines changed
  • sdks/typescript/runner/src

1 file changed

+65
-67
lines changed

sdks/typescript/runner/src/mod.ts

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ export class Runner {
137137
}
138138

139139
#stopAllActors() {
140-
console.log(
141-
"Stopping all actors due to runner lost threshold exceeded",
142-
);
140+
//console.log(
141+
// "Stopping all actors due to runner lost threshold exceeded",
142+
//);
143143

144144
const actorIds = Array.from(this.#actors.keys());
145145
for (const actorId of actorIds) {
@@ -214,7 +214,7 @@ export class Runner {
214214
if (this.#started) throw new Error("Cannot call runner.start twice");
215215
this.#started = true;
216216

217-
console.log("[RUNNER] Starting runner");
217+
//console.log("[RUNNER] Starting runner");
218218
await this.#openPegboardWebSocket();
219219
this.#openTunnel();
220220

@@ -285,10 +285,10 @@ export class Runner {
285285
} else {
286286
// Wait for actors to shut down befoer stopping
287287
try {
288-
console.log(
289-
"Sending stopping message",
290-
pegboardWebSocket.readyState,
291-
);
288+
//console.log(
289+
// "Sending stopping message",
290+
// pegboardWebSocket.readyState,
291+
//);
292292

293293
// NOTE: We don't use #sendToServer here because that function checks if the runner is
294294
// shut down
@@ -312,23 +312,23 @@ export class Runner {
312312
throw new Error("missing pegboardWebSocket");
313313

314314
pegboardWebSocket.addEventListener("close", (ev) => {
315-
console.log(
316-
"Connection closed",
317-
ev.code,
318-
ev.reason.toString(),
319-
);
315+
//console.log(
316+
// "Connection closed",
317+
// ev.code,
318+
// ev.reason.toString(),
319+
//);
320320
resolve();
321321
});
322322
});
323323

324324
// TODO: Wait for all actors to stop before closing ws
325325

326-
console.log("Closing WebSocket");
326+
//console.log("Closing WebSocket");
327327
pegboardWebSocket.close(1000, "Stopping");
328328

329329
await closePromise;
330330

331-
console.log("WebSocket shutdown completed");
331+
//console.log("WebSocket shutdown completed");
332332
} catch (error) {
333333
console.error("Error during WebSocket shutdown:", error);
334334
pegboardWebSocket.close();
@@ -341,7 +341,7 @@ export class Runner {
341341
// Close tunnel
342342
if (this.#tunnel) {
343343
this.#tunnel.shutdown();
344-
console.log("Tunnel shutdown completed");
344+
//console.log("Tunnel shutdown completed");
345345
}
346346

347347
if (exit) {
@@ -375,9 +375,9 @@ export class Runner {
375375

376376
#openTunnel() {
377377
const url = this.pegboardRelayUrl;
378-
console.log("[RUNNER] Opening tunnel to:", url);
379-
console.log("[RUNNER] Current runner ID:", this.runnerId || "none");
380-
console.log("[RUNNER] Active actors count:", this.#actors.size);
378+
//console.log("[RUNNER] Opening tunnel to:", url);
379+
//console.log("[RUNNER] Current runner ID:", this.runnerId || "none");
380+
//console.log("[RUNNER] Active actors count:", this.#actors.size);
381381

382382
this.#tunnel = new Tunnel(url);
383383
this.#tunnel.setCallbacks({
@@ -388,7 +388,7 @@ export class Runner {
388388

389389
// Re-register all active actors with the new tunnel
390390
for (const actorId of this.#actors.keys()) {
391-
console.log("[RUNNER] Re-registering actor with tunnel:", actorId);
391+
//console.log("[RUNNER] Re-registering actor with tunnel:", actorId);
392392
this.#tunnel.registerActor(actorId);
393393
}
394394
}
@@ -403,10 +403,8 @@ export class Runner {
403403
}) as any as WebSocket;
404404
this.#pegboardWebSocket = ws;
405405

406-
console.log(ws);
407-
408406
ws.addEventListener("open", () => {
409-
console.log("Connected");
407+
//console.log("Connected");
410408

411409
// Reset reconnect attempt counter on successful connection
412410
this.#reconnectAttempt = 0;
@@ -468,7 +466,7 @@ export class Runner {
468466
});
469467
} else {
470468
clearInterval(pingLoop);
471-
console.log("WebSocket not open, stopping ping loop");
469+
//console.log("WebSocket not open, stopping ping loop");
472470
}
473471
}, pingInterval);
474472
this.#pingLoop = pingLoop;
@@ -480,7 +478,7 @@ export class Runner {
480478
this.#sendCommandAcknowledgment();
481479
} else {
482480
clearInterval(ackLoop);
483-
console.log("WebSocket not open, stopping ack loop");
481+
//console.log("WebSocket not open, stopping ack loop");
484482
}
485483
}, ackInterval);
486484
this.#ackInterval = ackLoop;
@@ -509,16 +507,16 @@ export class Runner {
509507
? Number(init.metadata.runnerLostThreshold)
510508
: undefined;
511509

512-
console.log("Received init", {
513-
runnerId: init.runnerId,
514-
lastEventIdx: init.lastEventIdx,
515-
runnerLostThreshold: this.#runnerLostThreshold,
516-
});
510+
//console.log("Received init", {
511+
// runnerId: init.runnerId,
512+
// lastEventIdx: init.lastEventIdx,
513+
// runnerLostThreshold: this.#runnerLostThreshold,
514+
//});
517515

518516
// Reopen tunnel with runner ID
519-
console.log("[RUNNER] Received runner ID, reopening tunnel");
517+
//console.log("[RUNNER] Received runner ID, reopening tunnel");
520518
if (this.#tunnel) {
521-
console.log("[RUNNER] Shutting down existing tunnel");
519+
//console.log("[RUNNER] Shutting down existing tunnel");
522520
this.#tunnel.shutdown();
523521
}
524522
this.#openTunnel();
@@ -543,7 +541,7 @@ export class Runner {
543541
});
544542

545543
ws.addEventListener("close", (ev) => {
546-
console.log("Connection closed", ev.code, ev.reason.toString());
544+
//console.log("Connection closed", ev.code, ev.reason.toString());
547545

548546
this.#config.onDisconnected();
549547

@@ -565,9 +563,9 @@ export class Runner {
565563
this.#runnerLostThreshold &&
566564
this.#runnerLostThreshold > 0
567565
) {
568-
console.log(
569-
`Starting runner lost timeout: ${this.#runnerLostThreshold / 1000}s`,
570-
);
566+
//console.log(
567+
// `Starting runner lost timeout: ${this.#runnerLostThreshold / 1000}s`,
568+
//);
571569
this.#runnerLostTimeout = setTimeout(() => {
572570
this.#stopAllActors();
573571
}, this.#runnerLostThreshold);
@@ -580,12 +578,12 @@ export class Runner {
580578
}
581579

582580
#handleCommands(commands: protocol.ToClientCommands) {
583-
console.log("Received commands", {
584-
commandCount: commands.length,
585-
});
581+
//console.log("Received commands", {
582+
// commandCount: commands.length,
583+
//});
586584

587585
for (const commandWrapper of commands) {
588-
console.log("Received command", commandWrapper);
586+
//console.log("Received command", commandWrapper);
589587
if (commandWrapper.inner.tag === "CommandStartActor") {
590588
this.#handleCommandStartActor(commandWrapper);
591589
} else if (commandWrapper.inner.tag === "CommandStopActor") {
@@ -621,7 +619,7 @@ export class Runner {
621619

622620
// Register actor with tunnel
623621
if (this.#tunnel) {
624-
console.log("[RUNNER] Registering new actor with tunnel:", actorId);
622+
//console.log("[RUNNER] Registering new actor with tunnel:", actorId);
625623
this.#tunnel.registerActor(actorId);
626624
} else {
627625
console.error(
@@ -701,12 +699,12 @@ export class Runner {
701699
timestamp: Date.now(),
702700
});
703701

704-
console.log(
705-
"Sending event to server",
706-
eventWrapper.index,
707-
eventWrapper.inner.tag,
708-
eventWrapper.inner.val,
709-
);
702+
//console.log(
703+
// "Sending event to server",
704+
// eventWrapper.index,
705+
// eventWrapper.inner.tag,
706+
// eventWrapper.inner.val,
707+
//);
710708

711709
this.#sendToServer({
712710
tag: "ToServerEvents",
@@ -760,12 +758,12 @@ export class Runner {
760758
timestamp: Date.now(),
761759
});
762760

763-
console.log(
764-
"Sending event to server",
765-
eventWrapper.index,
766-
eventWrapper.inner.tag,
767-
eventWrapper.inner.val,
768-
);
761+
//console.log(
762+
// "Sending event to server",
763+
// eventWrapper.index,
764+
// eventWrapper.inner.tag,
765+
// eventWrapper.inner.val,
766+
//);
769767

770768
this.#sendToServer({
771769
tag: "ToServerEvents",
@@ -786,7 +784,7 @@ export class Runner {
786784
return;
787785
}
788786

789-
console.log("Sending command acknowledgment", this.#lastCommandIdx);
787+
//console.log("Sending command acknowledgment", this.#lastCommandIdx);
790788

791789
this.#sendToServer({
792790
tag: "ToServerAckCommands",
@@ -1159,7 +1157,7 @@ export class Runner {
11591157
}
11601158

11611159
if (processedCount > 0) {
1162-
console.log(`Processed ${processedCount} queued KV requests`);
1160+
//console.log(`Processed ${processedCount} queued KV requests`);
11631161
}
11641162
}
11651163

@@ -1184,7 +1182,7 @@ export class Runner {
11841182

11851183
#scheduleReconnect() {
11861184
if (this.#shutdown) {
1187-
console.log("Runner is shut down, not attempting reconnect");
1185+
//console.log("Runner is shut down, not attempting reconnect");
11881186
return;
11891187
}
11901188

@@ -1195,16 +1193,16 @@ export class Runner {
11951193
jitter: true,
11961194
});
11971195

1198-
console.log(
1199-
`Scheduling reconnect attempt ${this.#reconnectAttempt + 1} in ${delay}ms`,
1200-
);
1196+
//console.log(
1197+
// `Scheduling reconnect attempt ${this.#reconnectAttempt + 1} in ${delay}ms`,
1198+
//);
12011199

12021200
this.#reconnectTimeout = setTimeout(async () => {
12031201
if (!this.#shutdown) {
12041202
this.#reconnectAttempt++;
1205-
console.log(
1206-
`Attempting to reconnect (attempt ${this.#reconnectAttempt})...`,
1207-
);
1203+
//console.log(
1204+
// `Attempting to reconnect (attempt ${this.#reconnectAttempt})...`,
1205+
//);
12081206
await this.#openPegboardWebSocket();
12091207
}
12101208
}, delay);
@@ -1217,9 +1215,9 @@ export class Runner {
12171215

12181216
if (eventsToResend.length === 0) return;
12191217

1220-
console.log(
1221-
`Resending ${eventsToResend.length} unacknowledged events from index ${Number(lastEventIdx) + 1}`,
1222-
);
1218+
//console.log(
1219+
// `Resending ${eventsToResend.length} unacknowledged events from index ${Number(lastEventIdx) + 1}`,
1220+
//);
12231221

12241222
// Resend events in batches
12251223
const events = eventsToResend.map((item) => item.event);
@@ -1241,7 +1239,7 @@ export class Runner {
12411239

12421240
const prunedCount = originalLength - this.#eventHistory.length;
12431241
if (prunedCount > 0) {
1244-
console.log(`Pruned ${prunedCount} old events from history`);
1242+
//console.log(`Pruned ${prunedCount} old events from history`);
12451243
}
12461244
}
12471245

@@ -1265,7 +1263,7 @@ export class Runner {
12651263
}
12661264

12671265
if (toDelete.length > 0) {
1268-
console.log(`Cleaned up ${toDelete.length} expired KV requests`);
1266+
//console.log(`Cleaned up ${toDelete.length} expired KV requests`);
12691267
}
12701268
}
12711269
}

0 commit comments

Comments
 (0)