Skip to content

fix(client): apply the timeout option to every request - #12

Merged
Zernio-Elean merged 1 commit into
mainfrom
fix/client-timeout
Oct 16, 2026
Merged

Zernio-Elean merged 1 commit into
mainfrom
fix/client-timeout

Conversation

@Zernio-Elean

Copy link
Copy Markdown
Contributor

Why

ClientOptions.timeout was documented (default 60000) but never read, so a stalled request waited for undici's own limit (about 300s) and surfaced as fetch failed / terminated. It has been unwired since the initial commit.

What

  • _bind now gives each call signal: AbortSignal.timeout(timeout). hey-api spreads call options into the one Request, so no custom fetch or interceptor is needed.
  • A per-call signal replaces the timeout for that call (no AbortSignal.any, engines allows Node 18.0).
  • Default is now 300000: publishNow creates publish inside the request and the API allows up to 300s. 0 or Infinity disables it; other values are rounded up and capped so AbortSignal.timeout never throws.
  • The native TimeoutError propagates unwrapped.
  • Same edits in scripts/generate-client.ts, which generates src/client.ts.
  • tests/timeout.test.ts runs against a real local server. Before the fix the first test fails with Test timed out in 5000ms.
  • README config and CHANGELOG updated.

Follow-ups

  • The generated docs say the SDK sends an x-request-id, but the client sends none. A retried publishNow after a timeout can hit the duplicate check. Separate PR.
  • The CHANGELOG [Unreleased] heading needs the version once generate.yml publishes.

ClientOptions.timeout was documented with a 60000 default but never read,
so a stalled request waited for undici's own limit. Each bound operation
now gets AbortSignal.timeout(timeout); a per-call signal replaces it, 0 or
Infinity disables it, and the default is 300000 to cover synchronous
publishNow creates. Mirrored in scripts/generate-client.ts.
@Zernio-Elean
Zernio-Elean merged commit de277c8 into main Oct 16, 2026
2 checks passed
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.

1 participant