Skip to content
Merged
Changes from 5 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
23 changes: 22 additions & 1 deletion src/content/docs/workflows/build/sleeping-and-retrying.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let someState = step.do("call an API", {
}, async () => { /* Step code goes here /* }
```

## Force a Workflow to fail
## Force a Workflow instance to fail

You can also force a Workflow instance to fail and _not_ retry by throwing a `NonRetryableError` from within the step.

Expand All @@ -111,3 +111,24 @@ export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
```

The Workflow instance itself will fail immediately, no further steps will be invoked, and the Workflow will not be retried.

Like other Errors, any uncaught exceptions that propagate to the top level will cause the Workflow to end execution in an Errored state. Catch the `NonRetryableError` to continue Workflow execution:

```ts
...
try {
await step.do('task', async () => {
// work not to be retried
throw new NonRetryableError('oh no');
});
} catch {
console.log('error was thrown');
}

// the Workflow will not fail and will continue its execution

await step.do('next-task', async() => {
// more work to be done
});
...
```
Loading