Skip to content

Commit 2ea52da

Browse files
authored
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
1 parent 3493b94 commit 2ea52da

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.changeset/cyan-news-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Allow any runs to finish after SIGTERM but disable warm starts

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export class ManagedRunController {
3030
private readonly logger: RunLogger;
3131
private readonly taskRunProcessProvider: TaskRunProcessProvider;
3232

33+
private warmStartEnabled = true;
3334
private warmStartCount = 0;
35+
3436
private restoreCount = 0;
3537

3638
private notificationCount = 0;
@@ -103,7 +105,12 @@ export class ManagedRunController {
103105
runId: this.runFriendlyId,
104106
message: "Received SIGTERM, stopping worker",
105107
});
106-
await this.stop();
108+
109+
// Disable warm starts
110+
this.warmStartEnabled = false;
111+
112+
// ..now we wait for any active runs to finish
113+
// SIGKILL will handle the rest, nothing to do here
107114
});
108115
}
109116

@@ -276,6 +283,14 @@ export class ManagedRunController {
276283
* the process on any errors or when no runs are available after the configured duration.
277284
*/
278285
private async waitForNextRun() {
286+
if (!this.warmStartEnabled) {
287+
this.sendDebugLog({
288+
runId: this.runFriendlyId,
289+
message: "waitForNextRun: warm starts disabled, shutting down",
290+
});
291+
this.exitProcess(this.successExitCode);
292+
}
293+
279294
this.sendDebugLog({
280295
runId: this.runFriendlyId,
281296
message: "waitForNextRun()",
@@ -548,7 +563,7 @@ export class ManagedRunController {
548563
return;
549564
}
550565

551-
async stop() {
566+
async cancelRunsAndExitProcess() {
552567
this.sendDebugLog({
553568
runId: this.runFriendlyId,
554569
message: "Shutting down",
@@ -578,6 +593,9 @@ export class ManagedRunController {
578593

579594
// Close the socket
580595
this.socket.close();
596+
597+
// Exit the process
598+
this.exitProcess(this.successExitCode);
581599
}
582600

583601
sendDebugLog(opts: SendDebugLogOptions) {

0 commit comments

Comments
 (0)