From 71d0da8bef7013a40965eed6745b2b98b57ca523 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 3 Jul 2025 12:45:25 +0100 Subject: [PATCH 1/2] processKeepAlive disabled performance fix When processKeepAlive was disabled, the eagerly created TaskRunProcess being discarded and a whole new TaskRunProcess created at execution time. --- .../cli-v3/src/entryPoints/managed/execution.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/cli-v3/src/entryPoints/managed/execution.ts b/packages/cli-v3/src/entryPoints/managed/execution.ts index 17d945499c6..e9fa28356c8 100644 --- a/packages/cli-v3/src/entryPoints/managed/execution.ts +++ b/packages/cli-v3/src/entryPoints/managed/execution.ts @@ -145,6 +145,9 @@ export class RunExecution { throw new Error("prepareForExecution called after process was already created"); } + // Set the task run environment so canExecute returns true + this.currentTaskRunEnv = opts.taskRunEnv; + this.taskRunProcess = await this.taskRunProcessProvider.getProcess({ taskRunEnv: opts.taskRunEnv, isWarmStart: true, @@ -584,10 +587,15 @@ export class RunExecution { const taskRunEnv = this.currentTaskRunEnv ?? envVars; - this.taskRunProcess = await this.taskRunProcessProvider.getProcess({ - taskRunEnv: { ...taskRunEnv, TRIGGER_PROJECT_REF: execution.project.ref }, - isWarmStart, - }); + if (!this.taskRunProcess) { + this.sendDebugLog("getting new task run process", { runId: execution.run.id }); + this.taskRunProcess = await this.taskRunProcessProvider.getProcess({ + taskRunEnv: { ...taskRunEnv, TRIGGER_PROJECT_REF: execution.project.ref }, + isWarmStart, + }); + } else { + this.sendDebugLog("using prepared task run process", { runId: execution.run.id }); + } this.attachTaskRunProcessHandlers(this.taskRunProcess); From 6b20f3e45408d63b9626e0380d0ff46b1007331e Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 3 Jul 2025 13:13:59 +0100 Subject: [PATCH 2/2] Don't use a TaskRunProcess if it's being killed, fixes retryImmediately --- packages/cli-v3/src/entryPoints/managed/execution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-v3/src/entryPoints/managed/execution.ts b/packages/cli-v3/src/entryPoints/managed/execution.ts index e9fa28356c8..7b0245f4783 100644 --- a/packages/cli-v3/src/entryPoints/managed/execution.ts +++ b/packages/cli-v3/src/entryPoints/managed/execution.ts @@ -587,7 +587,7 @@ export class RunExecution { const taskRunEnv = this.currentTaskRunEnv ?? envVars; - if (!this.taskRunProcess) { + if (!this.taskRunProcess || this.taskRunProcess.isBeingKilled) { this.sendDebugLog("getting new task run process", { runId: execution.run.id }); this.taskRunProcess = await this.taskRunProcessProvider.getProcess({ taskRunEnv: { ...taskRunEnv, TRIGGER_PROJECT_REF: execution.project.ref },