Skip to Content
NineTwo's
Cookbook

Retries with backoff

Runnable coded-error retry example with a stable idempotency key.

The retry example is included in Errors and retries.

Key behaviors demonstrated:

  • Branches on the coded error.code envelope.
  • Retries only retryable codes (same_key_after_delay class).
  • Honours Retry-After when present; otherwise uses exponential backoff with jitter capped at 10 seconds.
  • Reuses one idempotency key and one identical payload across retries.
  • Does not retry idempotency_conflict, validation failures, or terminal_outcome.
  • Surfaces X-Request-Id and recovery guidance for uncertain outcomes.

See Errors and retries for the full source and Idempotency and recovery for no-ID recovery.