Fix: Prevent hung worker process on flush exceptions (#1501)

* deprecate cli logger warn and error methods

* replace broken error logger in deployed workers

* changeset
This commit is contained in:
nicktrn
2024-11-27 16:22:26 +00:00
committed by GitHub
parent 7e209e0771
commit 9046ea4f23
3 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Prevent certain log statements from hanging deployed worker processes
@@ -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();
@@ -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) {
+2
View File
@@ -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[]);