Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/core/src/v3/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/v3/workers/taskExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down