Skip to content
Merged
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
16 changes: 11 additions & 5 deletions aws-lambda-durable-functions-power/steering/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,29 @@ def handler(event: dict, context: DurableContext) -> dict:

## Unrecoverable Errors

Mark errors as unrecoverable to stop execution immediately:
Configure non-retryable failures to stop execution immediately:

**TypeScript:**

The TypeScript SDK does not currently expose a public unrecoverable error type.
Use a no-retry strategy when a step should fail immediately.

```typescript
import { UnrecoverableInvocationError } from '@aws/durable-execution-sdk-js';
import { retryPresets } from '@aws/durable-execution-sdk-js';

export const handler = withDurableExecution(async (event, context: DurableContext) => {
const user = await context.step('fetch-user', async () => {
const user = await fetchUser(event.userId);

if (!user) {
// Stop execution immediately - no retry
throw new UnrecoverableInvocationError('User not found');
// This error fails the step immediately because retryPresets.noRetry
// disables retries for this step.
throw new Error('User not found');
}

return user;
}, {
retryStrategy: retryPresets.noRetry,
});

// Continue processing...
Expand Down Expand Up @@ -422,7 +428,7 @@ export const handler = withDurableExecution(async (event, context: DurableContex
2. **Classify errors correctly** - distinguish retryable from non-retryable
3. **Implement compensating transactions** for distributed workflows
4. **Make errors deterministic** - same input produces same error
5. **Use unrecoverable errors** to stop execution early when appropriate
5. **Disable retries for non-retryable errors** to stop execution early when appropriate
6. **Log errors with context** using `context.logger`
7. **Handle partial failures** gracefully in batch operations
8. **Implement circuit breakers** for external service calls
Expand Down