Skip to content

Commit 589f7c3

Browse files
authored
v4: Fix HandleErrorFunction type (#1829)
* v4: Fix HandleErrorFunction type * Only show the catchError span if there are any catchError hooks
1 parent ff6359c commit 589f7c3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/core/src/v3/types/tasks.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ export type HandleErrorArgs = {
149149
signal?: AbortSignal;
150150
};
151151

152-
export type HandleErrorFunction = (
153-
payload: any,
154-
error: unknown,
155-
params: HandleErrorArgs
156-
) => HandleErrorResult;
152+
export type HandleErrorFunction = AnyOnCatchErrorHookFunction;
157153

158154
type CommonTaskOptions<
159155
TIdentifier extends string,

packages/core/src/v3/workers/taskExecutor.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,17 @@ export class TaskExecutor {
10361036
return { status: "skipped" };
10371037
}
10381038

1039+
const taskCatchErrorHook = lifecycleHooks.getTaskCatchErrorHook(this.task.id);
1040+
const globalCatchErrorHooks = lifecycleHooks.getGlobalCatchErrorHooks();
1041+
1042+
if (globalCatchErrorHooks.length === 0 && !taskCatchErrorHook) {
1043+
return { status: "noop" };
1044+
}
1045+
10391046
return this._tracer.startActiveSpan(
10401047
"catchError",
10411048
async (span) => {
10421049
// Try task-specific catch error hook first
1043-
const taskCatchErrorHook = lifecycleHooks.getTaskCatchErrorHook(this.task.id);
10441050
if (taskCatchErrorHook) {
10451051
const result = await taskCatchErrorHook({
10461052
payload,
@@ -1060,7 +1066,6 @@ export class TaskExecutor {
10601066
}
10611067

10621068
// Try global catch error hooks in order
1063-
const globalCatchErrorHooks = lifecycleHooks.getGlobalCatchErrorHooks();
10641069
for (const hook of globalCatchErrorHooks) {
10651070
const result = await hook.fn({
10661071
payload,

0 commit comments

Comments
 (0)