From 020a75257f6ea4a2b33461d3f79d63e47b4e2674 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 27 Mar 2025 14:35:08 +0000 Subject: [PATCH 1/2] v4: Fix HandleErrorFunction type --- packages/core/src/v3/types/tasks.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/core/src/v3/types/tasks.ts b/packages/core/src/v3/types/tasks.ts index 8c1e4d1014..53044c2f5e 100644 --- a/packages/core/src/v3/types/tasks.ts +++ b/packages/core/src/v3/types/tasks.ts @@ -149,11 +149,7 @@ export type HandleErrorArgs = { signal?: AbortSignal; }; -export type HandleErrorFunction = ( - payload: any, - error: unknown, - params: HandleErrorArgs -) => HandleErrorResult; +export type HandleErrorFunction = AnyOnCatchErrorHookFunction; type CommonTaskOptions< TIdentifier extends string, From af8d9797dd2a4d3512db42467db812a248ad90b1 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 27 Mar 2025 15:05:13 +0000 Subject: [PATCH 2/2] Only show the catchError span if there are any catchError hooks --- packages/core/src/v3/workers/taskExecutor.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/v3/workers/taskExecutor.ts b/packages/core/src/v3/workers/taskExecutor.ts index ce7a9f8246..6fbc207dcc 100644 --- a/packages/core/src/v3/workers/taskExecutor.ts +++ b/packages/core/src/v3/workers/taskExecutor.ts @@ -1036,11 +1036,17 @@ export class TaskExecutor { return { status: "skipped" }; } + const taskCatchErrorHook = lifecycleHooks.getTaskCatchErrorHook(this.task.id); + const globalCatchErrorHooks = lifecycleHooks.getGlobalCatchErrorHooks(); + + if (globalCatchErrorHooks.length === 0 && !taskCatchErrorHook) { + return { status: "noop" }; + } + return this._tracer.startActiveSpan( "catchError", async (span) => { // Try task-specific catch error hook first - const taskCatchErrorHook = lifecycleHooks.getTaskCatchErrorHook(this.task.id); if (taskCatchErrorHook) { const result = await taskCatchErrorHook({ payload, @@ -1060,7 +1066,6 @@ export class TaskExecutor { } // Try global catch error hooks in order - const globalCatchErrorHooks = lifecycleHooks.getGlobalCatchErrorHooks(); for (const hook of globalCatchErrorHooks) { const result = await hook.fn({ payload,