Skip to content

Commit e90235b

Browse files
authored
fix processKeepAlive disabled performance regression (#2228)
* processKeepAlive disabled performance fix When processKeepAlive was disabled, the eagerly created TaskRunProcess being discarded and a whole new TaskRunProcess created at execution time. * Don't use a TaskRunProcess if it's being killed, fixes retryImmediately
1 parent b7134dd commit e90235b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ export class RunExecution {
145145
throw new Error("prepareForExecution called after process was already created");
146146
}
147147

148+
// Set the task run environment so canExecute returns true
149+
this.currentTaskRunEnv = opts.taskRunEnv;
150+
148151
this.taskRunProcess = await this.taskRunProcessProvider.getProcess({
149152
taskRunEnv: opts.taskRunEnv,
150153
isWarmStart: true,
@@ -584,10 +587,15 @@ export class RunExecution {
584587

585588
const taskRunEnv = this.currentTaskRunEnv ?? envVars;
586589

587-
this.taskRunProcess = await this.taskRunProcessProvider.getProcess({
588-
taskRunEnv: { ...taskRunEnv, TRIGGER_PROJECT_REF: execution.project.ref },
589-
isWarmStart,
590-
});
590+
if (!this.taskRunProcess || this.taskRunProcess.isBeingKilled) {
591+
this.sendDebugLog("getting new task run process", { runId: execution.run.id });
592+
this.taskRunProcess = await this.taskRunProcessProvider.getProcess({
593+
taskRunEnv: { ...taskRunEnv, TRIGGER_PROJECT_REF: execution.project.ref },
594+
isWarmStart,
595+
});
596+
} else {
597+
this.sendDebugLog("using prepared task run process", { runId: execution.run.id });
598+
}
591599

592600
this.attachTaskRunProcessHandlers(this.taskRunProcess);
593601

0 commit comments

Comments
 (0)