Skip to content

Commit

Permalink
Add docs that mention attempt count in error handling sections
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Oct 20, 2023
1 parent 72a7fca commit feee12d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pages/docs/functions/retries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ export default inngest.createFunction(
);
```

## Attempt counter

Every time your function is executed, an `attempt` count is passed in as input, which is the current zero-based attempt number for this run.

The first attempt will be `0`, the second `1`, and so on. It is incremented every time the function throws an error and is retried.

```ts
inngest.createFunction(
{ id: "product-check" },
{ event: "product.check.requested" },
async ({ attempt }) => {
// `attempt` is the zero-based attempt number
}
);
```

If retries are caused by a step failing which then succeeds before retries are exhausted, `attempt` will reset back to `0`. See the [Errors within steps](#errors-within-steps) section below.

## Errors within steps

Steps are individually retried. That means Inngest will handle the type of error, just as above, but on the per-step basis.
Expand Down

0 comments on commit feee12d

Please sign in to comment.