Skip to content

[retry-core] Offer AbortSignal-aware retry and backoff cancellation #1712

Description

@kang-heewon

Priority: P1

Problem

Retry APIs have no AbortSignal and RetryEngine waits for backoff unconditionally. A cancelled request can remain queued and execute more attempts after its caller has ended.

Evidence

packages/retry-core/src/libs/RetryTemplate.ts and RetryOrchestrator.ts expose no signal; RetryEngine.ts:30-92 only stops through hooks and waits through the backoff policy.

Desired outcome

Retry work stops promptly and deterministically on caller cancellation.

Implementation path

  1. Add optional signal to template, orchestrator, engine, and decorator paths where applicable.
  2. Check cancellation before attempts and during backoff with an abortable wait.
  3. Emit a stable RetryAbortedProblem with safe context.
  4. Test before-first-attempt, during-backoff, listener cleanup, and no-further-attempt behavior.

Acceptance criteria

  • Cancellation prevents subsequent attempts.
  • Backoff does not outlive an aborted signal.
  • Existing retry behavior is unchanged when no signal is supplied.

Validation

pnpm --filter @croco/retry-core test

Scope boundaries

Does not redesign retry classification or backoff algorithms.

Metadata

Metadata

Assignees

Labels

P1Priority 1 issueruntimeRuntime behavior, lifecycle, and environment capability work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions