Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
5 changes: 5 additions & 0 deletions 5 .changeset/cold-laws-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Pass init output to both local and global `handleError` functions
15 changes: 8 additions & 7 deletions 15 packages/core/src/v3/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export type HandleErrorResult =

export type HandleErrorArgs = {
ctx: Context;
init: unknown;
retry?: RetryOptions;
retryAt?: Date;
retryDelayInMs?: number;
Expand All @@ -152,9 +153,9 @@ type CommonTaskOptions<
/** The retry settings when an uncaught error is thrown.
*
* If omitted it will use the values in your `trigger.config.ts` file.
*
*
* @example
*
*
* ```
* export const taskWithRetries = task({
id: "task-with-retries",
Expand All @@ -174,10 +175,10 @@ type CommonTaskOptions<
retry?: RetryOptions;

/** Used to configure what should happen when more than one run is triggered at the same time.
*
* @example
*
* @example
* one at a time execution
*
*
* ```ts
* export const oneAtATime = task({
id: "one-at-a-time",
Expand All @@ -192,9 +193,9 @@ type CommonTaskOptions<
*/
queue?: QueueOptions;
/** Configure the spec of the machine you want your task to run on.
*
*
* @example
*
*
* ```ts
* export const heavyTask = task({
id: "heavy-task",
Expand Down
4 changes: 4 additions & 0 deletions 4 packages/core/src/v3/workers/taskExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class TaskExecutor {
runError,
parsedPayload,
ctx,
initOutput,
signal
);

Expand Down Expand Up @@ -498,6 +499,7 @@ export class TaskExecutor {
error: unknown,
payload: any,
ctx: TaskRunContext,
init: unknown,
signal?: AbortSignal
): Promise<
| { status: "retry"; retry: TaskRunExecutionRetry; error?: unknown }
Expand Down Expand Up @@ -550,6 +552,7 @@ export class TaskExecutor {
const handleErrorResult = this.task.fns.handleError
? await this.task.fns.handleError(payload, error, {
ctx,
init,
retry,
retryDelayInMs: delay,
retryAt: delay ? new Date(Date.now() + delay) : undefined,
Expand All @@ -558,6 +561,7 @@ export class TaskExecutor {
: this._importedConfig
? await this._handleErrorFn?.(payload, error, {
ctx,
init,
retry,
retryDelayInMs: delay,
retryAt: delay ? new Date(Date.now() + delay) : undefined,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.