Skip to content

feat(retry): add cancellable retry function and decorator - #75

Closed
tabkram wants to merge 1 commit into
mainfrom
codex/73-retry
Closed

tabkram wants to merge 1 commit into
mainfrom
codex/73-retry

Conversation

@tabkram

@tabkram tabkram commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Adds retry(fn, options) and @retry(options) for transient failures. Both return a Promise for sync and async work, preserve arguments and receivers, and reject with the original final error and stack.

Includes bounded attempts, fixed/exponential/custom backoff, capped delays and full jitter, async context-based predicates and hooks, and per-call cancellation. Function wrappers accept withOptions({ signal }, ...args); decorators can select a signal from method arguments with getSignal. Cancellation clears pending delays and rejects with signal.reason.

When an engine is supplied or inferred from the receiver, retries appear as child attempt nodes under one operation, with failure reasons, delay narratives, and a final outcome. Works with @engine and @run. Adds package exports, API documentation and navigation.

Validation:

  • All 142 tests pass across 15 suites, including 49 new retry tests (npm test -- --runInBand --detectOpenHandles).
  • Targeted ESLint, TypeScript checks, package build, documentation build and commitlint pass.
  • Built-package smoke check covers exports, real delays, tracing and cancellation.

The issue follow-up's context-based hooks are used. Cancellation stops retry scheduling; underlying work must receive the signal itself to be interrupted.

Closes #73

Retry transient failures with bounded attempts, configurable backoff, async hooks
and per-call cancellation. Trace each attempt and final outcome while preserving
original errors and method receivers.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements
96.35% (+0.21% 🔼)
502/521
🟢 Branches
89.54% (+1.84% 🔼)
368/411
🟢 Functions
95.52% (+0.83% 🔼)
128/134
🟢 Lines
96.81% (+0.09% 🔼)
486/502
Show new covered files 🐣
St.❔
File Statements Branches Functions Lines
🟢 execution/retry.ts 97.17% 94.68% 100% 97.14%

Test suite run success

142 tests passing in 15 suites.

Report generated by 🧪jest coverage report action from b8a5f74

@tabkram tabkram closed this Nov 14, 2026
@tabkram
tabkram deleted the codex/73-retry branch November 14, 2026 22:23
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.

feat: add retry function and @retry decorator

1 participant