fix(runner): disable warm starts after SIGTERM (#2316)

* security: bump form-data to latest patch versions (CVE-2025-7783)

* disable warm starts on sigterm

* add changeset
This commit is contained in:
nicktrn
2025-07-28 11:29:49 +01:00
committed by GitHub
parent 3493b9464f
commit 2ea52da628
2 changed files with 25 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Allow any runs to finish after SIGTERM but disable warm starts
@@ -30,7 +30,9 @@ export class ManagedRunController {
private readonly logger: RunLogger;
private readonly taskRunProcessProvider: TaskRunProcessProvider;
private warmStartEnabled = true;
private warmStartCount = 0;
private restoreCount = 0;
private notificationCount = 0;
@@ -103,7 +105,12 @@ export class ManagedRunController {
runId: this.runFriendlyId,
message: "Received SIGTERM, stopping worker",
});
await this.stop();
// Disable warm starts
this.warmStartEnabled = false;
// ..now we wait for any active runs to finish
// SIGKILL will handle the rest, nothing to do here
});
}
@@ -276,6 +283,14 @@ export class ManagedRunController {
* the process on any errors or when no runs are available after the configured duration.
*/
private async waitForNextRun() {
if (!this.warmStartEnabled) {
this.sendDebugLog({
runId: this.runFriendlyId,
message: "waitForNextRun: warm starts disabled, shutting down",
});
this.exitProcess(this.successExitCode);
}
this.sendDebugLog({
runId: this.runFriendlyId,
message: "waitForNextRun()",
@@ -548,7 +563,7 @@ export class ManagedRunController {
return;
}
async stop() {
async cancelRunsAndExitProcess() {
this.sendDebugLog({
runId: this.runFriendlyId,
message: "Shutting down",
@@ -578,6 +593,9 @@ export class ManagedRunController {
// Close the socket
this.socket.close();
// Exit the process
this.exitProcess(this.successExitCode);
}
sendDebugLog(opts: SendDebugLogOptions) {