Skip to content

feat(client): retry a quote the router is too busy for after its retry-after - #48

Merged
pbennett merged 1 commit into
mainfrom
feat/retry-busy-quotes
Nov 16, 2026
Merged

pbennett merged 1 commit into
mainfrom
feat/retry-busy-quotes

Conversation

@pbennett

Copy link
Copy Markdown
Contributor

Summary

The router now bounds how many quotes a pod computes at once (TxnLab/haystack-router quoteGate, live on mainnet with the next router deploy). A quote it's too busy for, or one that runs past its 10 s deadline, is answered 503 Service Unavailable with Retry-After: 1.

request() now waits out that Retry-After and retries once, so a burst of load costs the caller a second rather than an error.

  • Retried: a 503 whose Retry-After is a number of seconds from 0 to 5.
  • Thrown as HTTPError, as before: a 429, any other 503 (no header, longer, or HTTP-date), and a second busy 503.
  • Aborting options.signal ends the wait.
  • The first response's body is read to its end before the retry, so its connection can be reused.

The README's Error Handling section and .claude/CLAUDE.md describe it. The developer docs already say "3.6.0 and later".

Release

feat → 3.6.0. It also releases the unreleased #45 (refactor(client): Tinyman v1 options deprecated as no-ops). hay.app and the mobile app pick up the retry when they bump the SDK.

Tests

pnpm run ci passes: build, lint, format, typecheck and 284 tests. The 10 new request tests run on fake timers and cover:

  • the retry after exactly Retry-After;
  • a second busy 503 thrown;
  • no retry without the header, over 5 s, with an HTTP-date or a negative value;
  • the 5 s boundary waited out;
  • 429 not retried;
  • abort during the wait.

…y-after

The router's quote gate answers a quote it is too busy to compute with 503
and Retry-After: 1. request() now waits that out and retries once, so a
burst of load costs the caller a second rather than an error. Only a 503
with a Retry-After of at most 5 seconds is retried; a 429, any other 503
and a second busy 503 are thrown as HTTPError as before. Aborting the
request's signal ends the wait.
@pbennett
pbennett merged commit 8c37aa2 into main Nov 16, 2026
1 check passed
@pbennett
pbennett deleted the feat/retry-busy-quotes branch November 16, 2026 20:06
txnlab-release-bot Bot added a commit that referenced this pull request Nov 16, 2026
# [3.6.0](v3.5.0...v3.6.0) (2026-11-16)

### Features

* **client:** retry a quote the router is too busy for after its retry-after ([#48](#48)) ([8c37aa2](8c37aa2))
@txnlab-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant