From 9046ea4f23e286f061792eface3fdbccfecaebce Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:22:26 +0000 Subject: [PATCH] Fix: Prevent hung worker process on flush exceptions (#1501) * deprecate cli logger warn and error methods * replace broken error logger in deployed workers * changeset --- .changeset/ninety-teachers-fold.md | 5 +++++ packages/cli-v3/src/executions/taskRunProcess.ts | 4 ++-- packages/cli-v3/src/utilities/logger.ts | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/ninety-teachers-fold.md diff --git a/.changeset/ninety-teachers-fold.md b/.changeset/ninety-teachers-fold.md new file mode 100644 index 000000000..7d40ec257 --- /dev/null +++ b/.changeset/ninety-teachers-fold.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Prevent certain log statements from hanging deployed worker processes diff --git a/packages/cli-v3/src/executions/taskRunProcess.ts b/packages/cli-v3/src/executions/taskRunProcess.ts index a3cc07098..22e3c9f6d 100644 --- a/packages/cli-v3/src/executions/taskRunProcess.ts +++ b/packages/cli-v3/src/executions/taskRunProcess.ts @@ -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) { diff --git a/packages/cli-v3/src/utilities/logger.ts b/packages/cli-v3/src/utilities/logger.ts index 640ceaa48..64a4b3fc1 100644 --- a/packages/cli-v3/src/utilities/logger.ts +++ b/packages/cli-v3/src/utilities/logger.ts @@ -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(data: TableRow[], level?: Exclude) { const keys: Keys[] = data.length === 0 ? [] : (Object.keys(data[0]!) as Keys[]);