Skip to content

Commit 13de462

Browse files
committed
chore(runner): disable default logs
1 parent cfb54d3 commit 13de462

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
@@ -140,9 +140,9 @@ export class Runner {
140140
}
141141

142142
#stopAllActors() {
143-
console.log(
144-
"Stopping all actors due to runner lost threshold exceeded",
145-
);
143+
//console.log(
144+
// "Stopping all actors due to runner lost threshold exceeded",
145+
//);
146146

147147
const actorIds = Array.from(this.#actors.keys());
148148
for (const actorId of actorIds) {
@@ -217,7 +217,7 @@ export class Runner {
217217
if (this.#started) throw new Error("Cannot call runner.start twice");
218218
this.#started = true;
219219

220-
console.log("[RUNNER] Starting runner");
220+
//console.log("[RUNNER] Starting runner");
221221
await this.#openPegboardWebSocket();
222222
this.#openTunnel();
223223

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

294294
this.#sendToServer({
295295
tag: "ToServerStopping",
@@ -301,23 +301,23 @@ export class Runner {
301301
throw new Error("missing pegboardWebSocket");
302302

303303
pegboardWebSocket.addEventListener("close", (ev) => {
304-
console.log(
305-
"Connection closed",
306-
ev.code,
307-
ev.reason.toString(),
308-
);
304+
//console.log(
305+
// "Connection closed",
306+
// ev.code,
307+
// ev.reason.toString(),
308+
//);
309309
resolve();
310310
});
311311
});
312312

313313
// TODO: Wait for all actors to stop before closing ws
314314

315-
console.log("Closing WebSocket");
315+
//console.log("Closing WebSocket");
316316
pegboardWebSocket.close(1000, "Stopping");
317317

318318
await closePromise;
319319

320-
console.log("WebSocket shutdown completed");
320+
//console.log("WebSocket shutdown completed");
321321
} catch (error) {
322322
console.error("Error during WebSocket shutdown:", error);
323323
pegboardWebSocket.close();
@@ -330,7 +330,7 @@ export class Runner {
330330
// Close tunnel
331331
if (this.#tunnel) {
332332
this.#tunnel.shutdown();
333-
console.log("Tunnel shutdown completed");
333+
//console.log("Tunnel shutdown completed");
334334
}
335335
}
336336

@@ -357,9 +357,9 @@ export class Runner {
357357

358358
#openTunnel() {
359359
const url = this.pegboardRelayUrl;
360-
console.log("[RUNNER] Opening tunnel to:", url);
361-
console.log("[RUNNER] Current runner ID:", this.runnerId || "none");
362-
console.log("[RUNNER] Active actors count:", this.#actors.size);
360+
//console.log("[RUNNER] Opening tunnel to:", url);
361+
//console.log("[RUNNER] Current runner ID:", this.runnerId || "none");
362+
//console.log("[RUNNER] Active actors count:", this.#actors.size);
363363

364364
this.#tunnel = new Tunnel(url);
365365
this.#tunnel.setCallbacks({
@@ -370,7 +370,7 @@ export class Runner {
370370

371371
// Re-register all active actors with the new tunnel
372372
for (const actorId of this.#actors.keys()) {
373-
console.log("[RUNNER] Re-registering actor with tunnel:", actorId);
373+
//console.log("[RUNNER] Re-registering actor with tunnel:", actorId);
374374
this.#tunnel.registerActor(actorId);
375375
}
376376
}
@@ -385,10 +385,8 @@ export class Runner {
385385
}) as any as WebSocket;
386386
this.#pegboardWebSocket = ws;
387387

388-
console.log(ws);
389-
390388
ws.addEventListener("open", () => {
391-
console.log("Connected");
389+
//console.log("Connected");
392390

393391
// Reset reconnect attempt counter on successful connection
394392
this.#reconnectAttempt = 0;
@@ -450,7 +448,7 @@ export class Runner {
450448
});
451449
} else {
452450
clearInterval(pingLoop);
453-
console.log("WebSocket not open, stopping ping loop");
451+
//console.log("WebSocket not open, stopping ping loop");
454452
}
455453
}, pingInterval);
456454
this.#pingLoop = pingLoop;
@@ -462,7 +460,7 @@ export class Runner {
462460
this.#sendCommandAcknowledgment();
463461
} else {
464462
clearInterval(ackLoop);
465-
console.log("WebSocket not open, stopping ack loop");
463+
//console.log("WebSocket not open, stopping ack loop");
466464
}
467465
}, ackInterval);
468466
this.#ackInterval = ackLoop;
@@ -489,16 +487,16 @@ export class Runner {
489487
// Store the runner lost threshold from metadata
490488
this.#runnerLostThreshold = init.metadata?.runnerLostThreshold ? Number(init.metadata.runnerLostThreshold) : undefined;
491489

492-
console.log("Received init", {
493-
runnerId: init.runnerId,
494-
lastEventIdx: init.lastEventIdx,
495-
runnerLostThreshold: this.#runnerLostThreshold,
496-
});
490+
//console.log("Received init", {
491+
// runnerId: init.runnerId,
492+
// lastEventIdx: init.lastEventIdx,
493+
// runnerLostThreshold: this.#runnerLostThreshold,
494+
//});
497495

498496
// Reopen tunnel with runner ID
499-
console.log("[RUNNER] Received runner ID, reopening tunnel");
497+
//console.log("[RUNNER] Received runner ID, reopening tunnel");
500498
if (this.#tunnel) {
501-
console.log("[RUNNER] Shutting down existing tunnel");
499+
//console.log("[RUNNER] Shutting down existing tunnel");
502500
this.#tunnel.shutdown();
503501
}
504502
this.#openTunnel();
@@ -523,7 +521,7 @@ export class Runner {
523521
});
524522

525523
ws.addEventListener("close", (ev) => {
526-
console.log("Connection closed", ev.code, ev.reason.toString());
524+
//console.log("Connection closed", ev.code, ev.reason.toString());
527525

528526
this.#config.onDisconnected();
529527

@@ -545,9 +543,9 @@ export class Runner {
545543
this.#runnerLostThreshold &&
546544
this.#runnerLostThreshold > 0
547545
) {
548-
console.log(
549-
`Starting runner lost timeout: ${this.#runnerLostThreshold / 1000}s`,
550-
);
546+
//console.log(
547+
// `Starting runner lost timeout: ${this.#runnerLostThreshold / 1000}s`,
548+
//);
551549
this.#runnerLostTimeout = setTimeout(() => {
552550
this.#stopAllActors();
553551
}, this.#runnerLostThreshold);
@@ -560,12 +558,12 @@ export class Runner {
560558
}
561559

562560
#handleCommands(commands: protocol.ToClientCommands) {
563-
console.log("Received commands", {
564-
commandCount: commands.length,
565-
});
561+
//console.log("Received commands", {
562+
// commandCount: commands.length,
563+
//});
566564

567565
for (const commandWrapper of commands) {
568-
console.log("Received command", commandWrapper);
566+
//console.log("Received command", commandWrapper);
569567
if (commandWrapper.inner.tag === "CommandStartActor") {
570568
this.#handleCommandStartActor(commandWrapper);
571569
} else if (commandWrapper.inner.tag === "CommandStopActor") {
@@ -601,7 +599,7 @@ export class Runner {
601599

602600
// Register actor with tunnel
603601
if (this.#tunnel) {
604-
console.log("[RUNNER] Registering new actor with tunnel:", actorId);
602+
//console.log("[RUNNER] Registering new actor with tunnel:", actorId);
605603
this.#tunnel.registerActor(actorId);
606604
} else {
607605
console.error("[RUNNER] WARNING: No tunnel available to register actor:", actorId);
@@ -678,12 +676,12 @@ export class Runner {
678676
timestamp: Date.now(),
679677
});
680678

681-
console.log(
682-
"Sending event to server",
683-
eventWrapper.index,
684-
eventWrapper.inner.tag,
685-
eventWrapper.inner.val,
686-
);
679+
//console.log(
680+
// "Sending event to server",
681+
// eventWrapper.index,
682+
// eventWrapper.inner.tag,
683+
// eventWrapper.inner.val,
684+
//);
687685

688686
this.#sendToServer({
689687
tag: "ToServerEvents",
@@ -737,12 +735,12 @@ export class Runner {
737735
timestamp: Date.now(),
738736
});
739737

740-
console.log(
741-
"Sending event to server",
742-
eventWrapper.index,
743-
eventWrapper.inner.tag,
744-
eventWrapper.inner.val,
745-
);
738+
//console.log(
739+
// "Sending event to server",
740+
// eventWrapper.index,
741+
// eventWrapper.inner.tag,
742+
// eventWrapper.inner.val,
743+
//);
746744

747745
this.#sendToServer({
748746
tag: "ToServerEvents",
@@ -763,7 +761,7 @@ export class Runner {
763761
return;
764762
}
765763

766-
console.log("Sending command acknowledgment", this.#lastCommandIdx);
764+
//console.log("Sending command acknowledgment", this.#lastCommandIdx);
767765

768766
this.#sendToServer({
769767
tag: "ToServerAckCommands",
@@ -1136,7 +1134,7 @@ export class Runner {
11361134
}
11371135

11381136
if (processedCount > 0) {
1139-
console.log(`Processed ${processedCount} queued KV requests`);
1137+
//console.log(`Processed ${processedCount} queued KV requests`);
11401138
}
11411139
}
11421140

@@ -1161,7 +1159,7 @@ export class Runner {
11611159

11621160
#scheduleReconnect() {
11631161
if (this.#shutdown) {
1164-
console.log("Runner is shut down, not attempting reconnect");
1162+
//console.log("Runner is shut down, not attempting reconnect");
11651163
return;
11661164
}
11671165

@@ -1172,16 +1170,16 @@ export class Runner {
11721170
jitter: true,
11731171
});
11741172

1175-
console.log(
1176-
`Scheduling reconnect attempt ${this.#reconnectAttempt + 1} in ${delay}ms`,
1177-
);
1173+
//console.log(
1174+
// `Scheduling reconnect attempt ${this.#reconnectAttempt + 1} in ${delay}ms`,
1175+
//);
11781176

11791177
this.#reconnectTimeout = setTimeout(async () => {
11801178
if (!this.#shutdown) {
11811179
this.#reconnectAttempt++;
1182-
console.log(
1183-
`Attempting to reconnect (attempt ${this.#reconnectAttempt})...`,
1184-
);
1180+
//console.log(
1181+
// `Attempting to reconnect (attempt ${this.#reconnectAttempt})...`,
1182+
//);
11851183
await this.#openPegboardWebSocket();
11861184
}
11871185
}, delay);
@@ -1194,9 +1192,9 @@ export class Runner {
11941192

11951193
if (eventsToResend.length === 0) return;
11961194

1197-
console.log(
1198-
`Resending ${eventsToResend.length} unacknowledged events from index ${Number(lastEventIdx) + 1}`,
1199-
);
1195+
//console.log(
1196+
// `Resending ${eventsToResend.length} unacknowledged events from index ${Number(lastEventIdx) + 1}`,
1197+
//);
12001198

12011199
// Resend events in batches
12021200
const events = eventsToResend.map((item) => item.event);
@@ -1218,7 +1216,7 @@ export class Runner {
12181216

12191217
const prunedCount = originalLength - this.#eventHistory.length;
12201218
if (prunedCount > 0) {
1221-
console.log(`Pruned ${prunedCount} old events from history`);
1219+
//console.log(`Pruned ${prunedCount} old events from history`);
12221220
}
12231221
}
12241222

@@ -1242,7 +1240,7 @@ export class Runner {
12421240
}
12431241

12441242
if (toDelete.length > 0) {
1245-
console.log(`Cleaned up ${toDelete.length} expired KV requests`);
1243+
//console.log(`Cleaned up ${toDelete.length} expired KV requests`);
12461244
}
12471245
}
12481246
}

0 commit comments

Comments
 (0)