Skip to content

feat(sdk): add specific error types for callback operations#441

Merged
ParidelPooya merged 16 commits intomainfrom
feat/callback-error-types
Feb 23, 2026
Merged

feat(sdk): add specific error types for callback operations#441
ParidelPooya merged 16 commits intomainfrom
feat/callback-error-types

Conversation

@ParidelPooya
Copy link
Copy Markdown
Contributor

Add CallbackTimeoutError and CallbackSubmitterError to provide clear, unambiguous error handling for callback operations. Replace errorClass with more flexible errorMapper in ChildConfig.

Changes:

  • Add CallbackTimeoutError for callback timeout scenarios
  • Add CallbackSubmitterError for submitter failures in waitForCallback
  • Add errorMapper to ChildConfig for flexible error type mapping
  • Remove errorClass from ChildConfig (replaced by errorMapper)
  • Update callback.ts to throw CallbackTimeoutError for TIMED_OUT status
  • Update waitForCallback to use errorMapper for consistent error types
  • Update all promise combinators to use errorMapper
  • Update fromErrorObject to reconstruct new error types
  • Export CallbackTimeoutError and CallbackSubmitterError
  • Update all tests to expect correct error types

Error types by operation:

  • createCallback timeout -> CallbackTimeoutError
  • createCallback failure -> CallbackError
  • waitForCallback timeout -> CallbackTimeoutError
  • waitForCallback failure -> CallbackError
  • waitForCallback submitter failure -> CallbackSubmitterError

Benefits:

  • Users can catch specific error types without parsing error messages
  • Consistent error handling across createCallback and waitForCallback
  • More flexible error customization via errorMapper
  • Type-safe error handling in TypeScript

Issue #, if available:
#420

Add CallbackTimeoutError and CallbackSubmitterError to provide clear,
unambiguous error handling for callback operations. Replace errorClass
with more flexible errorMapper in ChildConfig.

Changes:
- Add CallbackTimeoutError for callback timeout scenarios
- Add CallbackSubmitterError for submitter failures in waitForCallback
- Add errorMapper to ChildConfig for flexible error type mapping
- Remove errorClass from ChildConfig (replaced by errorMapper)
- Update callback.ts to throw CallbackTimeoutError for TIMED_OUT status
- Update waitForCallback to use errorMapper for consistent error types
- Update all promise combinators to use errorMapper
- Update fromErrorObject to reconstruct new error types
- Export CallbackTimeoutError and CallbackSubmitterError
- Update all tests to expect correct error types

Error types by operation:
- createCallback timeout -> CallbackTimeoutError
- createCallback failure -> CallbackError
- waitForCallback timeout -> CallbackTimeoutError
- waitForCallback failure -> CallbackError
- waitForCallback submitter failure -> CallbackSubmitterError

Benefits:
- Users can catch specific error types without parsing error messages
- Consistent error handling across createCallback and waitForCallback
- More flexible error customization via errorMapper
- Type-safe error handling in TypeScript

Fixes #420
Remove try-catch in wait-for-callback-timeout example to allow
CallbackTimeoutError to propagate correctly. Update history.json
to reflect ExecutionFailed instead of ExecutionSucceeded.
Add example that catches callback timeout error, waits, then checks
error instance type in a step. Verifies that caught error is correctly
identified as CallbackTimeoutError instance with proper name and message.

This confirms error reconstruction works correctly across replays.
Move create-callback error-instance test to create-callback/error-instance.
Add wait-for-callback error-instance test to wait-for-callback/error-instance.

Both tests verify that CallbackTimeoutError instanceof checks work correctly
across replays for their respective callback operations.
Update error-instance tests to verify all error types:
- createCallback: CallbackTimeoutError, CallbackError
- waitForCallback: CallbackTimeoutError, CallbackSubmitterError

Each test catches multiple errors, waits, then checks instanceof in a step
to verify error types persist correctly across replays.
…or types

Test verifies instanceof checks work for:
- CallbackError (callback failure via sendCallbackFailure)
- CallbackTimeoutError (callback timeout)
- CallbackSubmitterError (submitter throws error)

Named callbacks for better test readability and uses InvocationType.Event
to match other waitForCallback tests.
Add 30s timeout to first callback to prevent cloud integration test from
hanging indefinitely. Local tests send failure quickly, but cloud tests
need a safety timeout.
Add invocationCompletedDifference: 1 to handle timing differences between
local and cloud test execution.
Reduce first callback timeout from 30s to 10s to make test fail faster
if callback interaction doesn't happen in time. This prevents long waits
in cloud integration tests.
Split waitForCallback error-instance test into 3 separate test suites,
each with its own handler:
- handlerFailure: tests CallbackError
- handlerTimeout: tests CallbackTimeoutError
- handlerSubmitter: tests CallbackSubmitterError

This makes each test faster and less likely to timeout in cloud
integration tests, while still comprehensively testing all error types.
Add console.log to see what the actual result structure is in cloud
execution when the test fails.
Each error type (failure, timeout, submitter) now has its own directory
with separate handler and test. This ensures each test deploys to its
own cloud function, fixing the issue where all tests were running
against the same handler in cloud execution.

- error-instance-failure: Tests CallbackError from sendCallbackFailure
- error-instance-timeout: Tests CallbackTimeoutError from 1s timeout
- error-instance-submitter: Tests CallbackSubmitterError from submitter throw

All tests passing locally.
…stance test

The test was missing invocationType: InvocationType.Event, causing
cloud tests to fail with 'InvocationType.undefined cannot wait for
operation data'.
Lambda function names cannot contain parentheses. Changed:
- 'Error Instance (Failure)' -> 'Error Instance Failure'
- 'Error Instance (Timeout)' -> 'Error Instance Timeout'
- 'Error Instance (Submitter)' -> 'Error Instance Submitter'

This fixes ValidationException in cloud tests.
The submitter step was retrying 5 times with exponential backoff,
taking ~2 minutes. This caused cloud tests to timeout at 60 seconds.

Added retryStrategy: () => ({ shouldRetry: false }) to make the
submitter fail immediately without retries.
@yaythomas
Copy link
Copy Markdown

for python aws/aws-durable-execution-sdk-python#313

@ParidelPooya ParidelPooya marked this pull request as ready for review February 23, 2026 17:26
@ParidelPooya ParidelPooya merged commit 266b070 into main Feb 23, 2026
30 of 31 checks passed
@ParidelPooya ParidelPooya deleted the feat/callback-error-types branch February 23, 2026 19:08
@zhongkechen
Copy link
Copy Markdown

similar for java sdk: aws/aws-durable-execution-sdk-java#147

ParidelPooya added a commit that referenced this pull request Mar 9, 2026
ParidelPooya added a commit that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants