Skip to content

docs(typescript): align step-interrupted contract#193

Merged
yaythomas merged 1 commit into
mainfrom
docs/typescript-step-interrupted-error-contract
May 26, 2026
Merged

docs(typescript): align step-interrupted contract#193
yaythomas merged 1 commit into
mainfrom
docs/typescript-step-interrupted-error-contract

Conversation

@yaythomas
Copy link
Copy Markdown
Contributor

Fixes #192.

Summary

The TypeScript tab of the Error handling: errors page tells customers to detect step interruption with instanceof StepInterruptedError, but the JS SDK does not throw StepInterruptedError from await context.step(...). It throws a StepError whose cause.name equals "StepInterruptedError".

The wrapping has always been the SDK's behaviour on this code path. A separate bug (aws-durable-execution-sdk-js#529) masked the divergence by crashing before the throw line; aws-durable-execution-sdk-js#576 fixes that crash and codifies the contract via unit and e2e tests.

Python and Java tabs remain accurate.

Changes

  • docs/sdk-reference/error-handling/errors.md: rewrite the StepInterruptedError prose paragraph in the "Exception types" TypeScript tab; relabel the SIE mermaid node so the diagram does not imply StepInterruptedError surfaces as a thrown error.
  • docs/sdk-reference/operations/step.md: update the TypeScript step() Throws note and the AtMostOncePerRetry semantics description.
  • examples/typescript/sdk-reference/error-handling/step-interrupted.ts: detect interruption via err instanceof StepError && err.cause?.name === "StepInterruptedError". Drop the emdash in the logger.warn message.
  • examples/typescript/sdk-reference/error-handling/exception-hierarchy.ts: rewrite the trailing comment block. Keep StepInterruptedError in the import/export list because it remains useful for typing the error argument of a retryStrategy callback.

Verification

  • Read the JS SDK source to confirm the actual contract on the interrupted-step + AT_MOST_ONCE_PER_RETRY path:
    • step-handler.ts throws DurableOperationError.fromErrorObject(createErrorObjectFromError(StepInterruptedError)).
    • createErrorObjectFromError produces { ErrorType: "StepInterruptedError", ... }.
    • DurableOperationError.fromErrorObject falls through its switch to the default branch and returns a StepError whose cause is a plain Error with name === "StepInterruptedError".
  • Confirmed StepError, DurableOperationError, and StepInterruptedError are all public exports of @aws/durable-execution-sdk-js.
  • Confirmed every StepInterruptedError mention across the docs (errors.md, step.md, the two example files). Python and Java mentions are correct as-is and untouched.
  • Ran ~/.venvs/zensical/bin/mdformat on the modified Markdown files.
  • Ran ~/.venvs/zensical/bin/zensical build --clean: build succeeds with no warnings.

Out of scope

  • Python and Java tabs of the affected pages.
  • examples/typescript/sdk-reference/error-handling/step-interrupted-error.ts (currently a // Coming soon... placeholder).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Fixes #192. The TypeScript SDK does not throw StepInterruptedError
from `await context.step(...)`. The SDK throws a StepError whose
cause.name equals "StepInterruptedError". Update four files to
reflect this.

- errors.md: rewrite the StepInterruptedError prose paragraph in
  the "Exception types" TypeScript tab and relabel the SIE mermaid
  node.
- step.md: update the TypeScript step() Throws note and the
  AtMostOncePerRetry semantics description.
- step-interrupted.ts: detect interruption via
  err instanceof StepError && err.cause?.name ===
  "StepInterruptedError".
- exception-hierarchy.ts: rewrite the trailing comment block.

Python and Java tabs remain accurate. Their SDKs raise or throw
the language-specific class directly per their respective
hierarchies.

Context: aws/aws-durable-execution-sdk-js#576 fixes the metadata
crash that masked this divergence on cold replay and codifies the
wrapping contract via unit and e2e tests.
@yaythomas yaythomas merged commit b92e997 into main May 26, 2026
4 checks passed
@yaythomas yaythomas deleted the docs/typescript-step-interrupted-error-contract branch May 26, 2026 20:24
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.

docs(typescript): align "Step interrupted" guidance with SDK behaviour

2 participants