Skip to content

fix(api): abort rate-limit retry backoff - #2004

Open
Osraka wants to merge 1 commit into
ProjectOpenSea:mainfrom
Osraka:osraka/abort-rate-limit-backoff
Open

fix(api): abort rate-limit retry backoff#2004
Osraka wants to merge 1 commit into
ProjectOpenSea:mainfrom
Osraka:osraka/abort-rate-limit-backoff

Conversation

@Osraka

@Osraka Osraka commented Aug 24, 2026

Copy link
Copy Markdown

Motivation

Closes #2003

RequestOptions.signal reaches each individual fetch attempt, but it does not reach the delay between rate-limit retries. If a caller aborts after a 429/599 response, the API promise remains pending for the full backoff (up to the five-minute Retry-After cap), then starts another attempt before _fetch notices the already-aborted signal.

This makes cancellation timing-dependent: it works before or during a fetch, but not while that same request is waiting to retry.

Solution

Allow RateLimitOptions to receive an optional signal and use it only to cancel a pending retry delay. OpenSeaAPI.get and OpenSeaAPI.request now pass their existing request signal into the retry layer. Aborting clears the pending timer, removes the event listener, rejects with the existing Request aborted message, and does not start another attempt.

The change does not alter retry counts, 429/599 detection, Retry-After parsing, timeout semantics, or non-aborted retry behavior.

Regression coverage verifies:

  • executeWithRateLimit rejects promptly when aborted during backoff
  • neither get nor request starts a second attempt after cancellation
  • the three tests fail on current main with the promise still pending

Validation:

  • npm run build
  • npm run check-types
  • npm run lint (passes with the existing unrelated Function warning)
  • npm test (47 files, 1010 tests)

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.

AbortSignal does not cancel rate-limit retry backoff

1 participant