Skip to content

Commit 049d104

Browse files
committed
prevent snapshot change handler from running after execution stopped
1 parent 2f9e590 commit 049d104

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class RunExecution {
6666
private snapshotPoller?: RunExecutionSnapshotPoller;
6767

6868
private lastHeartbeat?: Date;
69+
private isShuttingDown = false;
6970

7071
constructor(opts: RunExecutionOptions) {
7172
this.id = randomBytes(4).toString("hex");
@@ -163,6 +164,11 @@ export class RunExecution {
163164
* or when the snapshot poller detects a change
164165
*/
165166
public async handleSnapshotChange(runData: RunExecutionData): Promise<void> {
167+
if (this.isShuttingDown) {
168+
this.sendDebugLog("handleSnapshotChange: shutting down, skipping");
169+
return;
170+
}
171+
166172
const { run, snapshot, completedWaitpoints } = runData;
167173

168174
const snapshotMetadata = {
@@ -985,6 +991,11 @@ export class RunExecution {
985991
}
986992

987993
private stopServices() {
994+
if (this.isShuttingDown) {
995+
return;
996+
}
997+
998+
this.isShuttingDown = true;
988999
this.snapshotPoller?.stop();
9891000
this.taskRunProcess?.onTaskRunHeartbeat.detach();
9901001
}

0 commit comments

Comments
 (0)