From 98106454adf300dc03445133208f083eaa3d5bd8 Mon Sep 17 00:00:00 2001 From: Pratik Mahajan Date: Sun, 26 Jan 2025 14:33:50 +0530 Subject: [PATCH 1/2] feat : Errors thrown in onStart should fail the run with that error --- references/bun-catalog/trigger.config.ts | 7 ++++++- references/v3-catalog/trigger.config.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/references/bun-catalog/trigger.config.ts b/references/bun-catalog/trigger.config.ts index a2deb7398e..714714b6a7 100644 --- a/references/bun-catalog/trigger.config.ts +++ b/references/bun-catalog/trigger.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from "@trigger.dev/sdk/v3"; +import { logger } from "../../packages/core/dist/commonjs/v3/logger-api.js"; export default defineConfig({ runtime: "bun", @@ -18,7 +19,11 @@ export default defineConfig({ enableConsoleLogging: false, logLevel: "info", onStart: async (payload, { ctx }) => { - console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); + try { + console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); + } catch (error) { + console.log(error) + } }, onFailure: async (payload, error, { ctx }) => { console.log(`Task ${ctx.task.id} failed ${ctx.run.id}`); diff --git a/references/v3-catalog/trigger.config.ts b/references/v3-catalog/trigger.config.ts index 18ac1ec734..75310841e9 100644 --- a/references/v3-catalog/trigger.config.ts +++ b/references/v3-catalog/trigger.config.ts @@ -31,7 +31,11 @@ export default defineConfig({ enableConsoleLogging: false, logLevel: "info", onStart: async (payload, { ctx }) => { - console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); + try { + console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); + } catch (error) { + console.log(error) + } }, onFailure: async (payload, error, { ctx }) => { console.log( From a3fc6dc57275701f3ee4f254dcfbcc576f0528b6 Mon Sep 17 00:00:00 2001 From: Pratik Mahajan Date: Sun, 26 Jan 2025 16:50:10 +0530 Subject: [PATCH 2/2] fixes --- references/bun-catalog/trigger.config.ts | 1 + references/v3-catalog/trigger.config.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/references/bun-catalog/trigger.config.ts b/references/bun-catalog/trigger.config.ts index 714714b6a7..c58a56447c 100644 --- a/references/bun-catalog/trigger.config.ts +++ b/references/bun-catalog/trigger.config.ts @@ -23,6 +23,7 @@ export default defineConfig({ console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); } catch (error) { console.log(error) + throw error; // Re-throw to fail the run } }, onFailure: async (payload, error, { ctx }) => { diff --git a/references/v3-catalog/trigger.config.ts b/references/v3-catalog/trigger.config.ts index 75310841e9..801822da6b 100644 --- a/references/v3-catalog/trigger.config.ts +++ b/references/v3-catalog/trigger.config.ts @@ -34,7 +34,12 @@ export default defineConfig({ try { console.log(`Task ${ctx.task.id} started ${ctx.run.id}`); } catch (error) { - console.log(error) + console.log( + `Task ${ctx.task.id} failed ${ctx.run.id}: ${ + error instanceof Error ? error.message : String(error) + }` + ); + throw error; // Re-throw to fail the run } }, onFailure: async (payload, error, { ctx }) => {