Skip to content

Commit 344e2e5

Browse files
committed
better debug logs
1 parent 213a983 commit 344e2e5

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

packages/cli-v3/src/entryPoints/managed/execution.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,7 @@ export class RunExecution {
443443
logger: this.logger,
444444
snapshotPollIntervalSeconds: this.env.TRIGGER_SNAPSHOT_POLL_INTERVAL_SECONDS,
445445
handleSnapshotChange: this.enqueueSnapshotChangeAndWait.bind(this),
446-
});
447-
448-
this.snapshotPoller.start();
446+
}).start();
449447

450448
const [startError, start] = await tryCatch(
451449
this.startAttempt({ isWarmStart: runOpts.isWarmStart })
@@ -500,7 +498,7 @@ export class RunExecution {
500498
}
501499

502500
if (executeError instanceof SuspendedProcessError) {
503-
this.sendDebugLog("run was suspended", {
501+
this.sendDebugLog("execution was suspended", {
504502
run: run.friendlyId,
505503
snapshot: snapshot.friendlyId,
506504
error: executeError.message,
@@ -510,7 +508,7 @@ export class RunExecution {
510508
}
511509

512510
if (executeError instanceof ExecutionAbortError) {
513-
this.sendDebugLog("run was interrupted", {
511+
this.sendDebugLog("execution was aborted", {
514512
run: run.friendlyId,
515513
snapshot: snapshot.friendlyId,
516514
error: executeError.message,
@@ -981,7 +979,7 @@ export class RunExecution {
981979
this.shutdownReason = reason;
982980

983981
this.snapshotPoller?.stop();
984-
this.snapshotManager?.cleanup();
982+
this.snapshotManager?.dispose();
985983

986984
this.taskRunProcess?.unsafeDetachEvtHandlers();
987985
}

packages/cli-v3/src/entryPoints/managed/poller.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export class RunExecutionSnapshotPoller {
6363
});
6464
},
6565
});
66-
67-
this.sendDebugLog("created");
6866
}
6967

7068
private sendDebugLog(message: string, properties?: SendDebugLogOptions["properties"]) {
@@ -93,14 +91,18 @@ export class RunExecutionSnapshotPoller {
9391
this.poller.updateInterval(intervalMs);
9492
}
9593

96-
start() {
94+
start(): RunExecutionSnapshotPoller {
9795
if (this.enabled) {
9896
this.sendDebugLog("already started");
99-
return;
97+
return this;
10098
}
10199

100+
this.sendDebugLog("start");
101+
102102
this.enabled = true;
103103
this.poller.start();
104+
105+
return this;
104106
}
105107

106108
stop() {
@@ -109,12 +111,14 @@ export class RunExecutionSnapshotPoller {
109111
return;
110112
}
111113

114+
this.sendDebugLog("stop");
115+
112116
this.enabled = false;
113117

114118
const { isExecuting } = this.poller.stop();
115119

116120
if (isExecuting) {
117-
this.sendDebugLog("stopped poller but it's still executing");
121+
this.sendDebugLog("stopped while executing");
118122
}
119123
}
120124
}

packages/cli-v3/src/entryPoints/managed/snapshot.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ describe("SnapshotManager", () => {
306306

307307
expect(manager.queueLength).not.toBe(0);
308308

309-
// Call cleanup before they complete
310-
manager.cleanup();
309+
// Dispose manager before any promises complete
310+
manager.dispose();
311311

312312
expect(manager.queueLength).toBe(0);
313313

packages/cli-v3/src/entryPoints/managed/snapshot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,12 @@ export class SnapshotManager {
286286
}
287287
}
288288

289-
public cleanup() {
289+
public dispose() {
290+
this.sendDebugLog("dispose");
291+
290292
// Clear any pending changes
291293
for (const item of this.changeQueue) {
292-
item.reject(new Error("SnapshotManager cleanup"));
294+
item.reject(new Error("SnapshotManager disposed"));
293295
}
294296
this.changeQueue = [];
295297
}

0 commit comments

Comments
 (0)