Skip to content

Commit b82db67

Browse files
committed
Add additional logging around cleaning up dev workers, and always kill them after 5 seconds if they haven't already exited
1 parent 2609389 commit b82db67

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.changeset/shiny-coats-cry.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+
Add additional logging around cleaning up dev workers, and always kill them after 5 seconds if they haven't already exited

packages/cli-v3/src/workers/dev/backgroundWorker.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,15 @@ class TaskRunProcess {
627627
});
628628

629629
this._isBeingKilled = kill;
630+
631+
// Set a timeout to kill the child process if it hasn't been killed within 5 seconds
632+
setTimeout(() => {
633+
if (this._child && !this._child.killed) {
634+
logger.debug(`[${this.execution.run.id}] killing task run process after timeout`);
635+
636+
this._child.kill();
637+
}
638+
}, 5000);
630639
}
631640

632641
async executeTaskRun(payload: TaskRunExecutionPayload): Promise<TaskRunExecutionResult> {
@@ -709,6 +718,8 @@ class TaskRunProcess {
709718
break;
710719
}
711720
case "READY_TO_DISPOSE": {
721+
logger.debug(`[${this.execution.run.id}] task run process is ready to dispose`);
722+
712723
this.#kill();
713724

714725
break;
@@ -791,6 +802,8 @@ class TaskRunProcess {
791802

792803
#kill() {
793804
if (this._child && !this._child.killed) {
805+
logger.debug(`[${this.execution.run.id}] killing task run process`);
806+
794807
this._child?.kill();
795808
}
796809
}

0 commit comments

Comments
 (0)