Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/cli-v3/src/entryPoints/managed/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class RunExecution {
private isShuttingDown = false;
private shutdownReason?: string;

private isCompletingRun = false;

private supervisorSocket: SupervisorSocket;
private notifier?: RunNotifier;
private metadataClient?: MetadataClient;
Expand Down Expand Up @@ -292,7 +294,13 @@ export class RunExecution {
case "FINISHED": {
this.sendDebugLog("run is finished", snapshotMetadata);

// This can sometimes be called before the handleCompletionResult, so we don't need to do anything here
// We are finishing the run in handleCompletionResult, so we don't need to do anything here
if (this.isCompletingRun) {
this.sendDebugLog("run is finished but we're completing it, skipping", snapshotMetadata);
return;
}

await this.exitTaskRunProcessWithoutFailingRun({ flush: true, reason: "re-queued" });
return;
}
case "QUEUED_EXECUTING":
Expand Down Expand Up @@ -377,6 +385,9 @@ export class RunExecution {
throw new Error("Cannot start attempt: missing run or snapshot manager");
}

// Reset this for the new attempt
this.isCompletingRun = false;

this.sendDebugLog("starting attempt", { isWarmStart: String(isWarmStart) });

const attemptStartedAt = Date.now();
Expand Down Expand Up @@ -655,6 +666,8 @@ export class RunExecution {
throw new Error("cannot complete run: missing run or snapshot manager");
}

this.isCompletingRun = true;

const completionResult = await this.httpClient.completeRunAttempt(
this.runFriendlyId,
this.snapshotManager.snapshotId,
Expand Down