Skip to content

Commit

Permalink
Fix: Prevent hung worker process on flush exceptions (#1501)
Browse files Browse the repository at this point in the history
* deprecate cli logger warn and error methods

* replace broken error logger in deployed workers

* changeset
  • Loading branch information
nicktrn authored Nov 27, 2024
1 parent 7e209e0 commit 9046ea4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-teachers-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Prevent certain log statements from hanging deployed worker processes
4 changes: 2 additions & 2 deletions packages/cli-v3/src/executions/taskRunProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class TaskRunProcess {
try {
await this.#flush();
} catch (err) {
logger.error("Error flushing task run process", { err });
console.error("Error flushing task run process", { err });
}

await this.kill();
Expand All @@ -94,7 +94,7 @@ export class TaskRunProcess {
try {
await this.#flush();
} catch (err) {
logger.error("Error flushing task run process", { err });
console.error("Error flushing task run process", { err });
}

if (kill) {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-v3/src/utilities/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class Logger {
};
info = (...args: unknown[]) => this.doLog("info", args);
log = (...args: unknown[]) => this.doLog("log", args);
/** @deprecated **ONLY USE THIS IN THE CLI** - It will hang the process when used in deployed code (!) */
warn = (...args: unknown[]) => this.doLog("warn", args);
/** @deprecated **ONLY USE THIS IN THE CLI** - It will hang the process when used in deployed code (!) */
error = (...args: unknown[]) => this.doLog("error", args);
table<Keys extends string>(data: TableRow<Keys>[], level?: Exclude<LoggerLevel, "none">) {
const keys: Keys[] = data.length === 0 ? [] : (Object.keys(data[0]!) as Keys[]);
Expand Down

0 comments on commit 9046ea4

Please sign in to comment.