Skip to content

fix: enforce configured request timeout - #15

Merged
bufo24 merged 1 commit into
mainfrom
fix/apply-request-timeout
Jul 7, 2026
Merged

fix: enforce configured request timeout#15
bufo24 merged 1 commit into
mainfrom
fix/apply-request-timeout

Conversation

@bufo24

@bufo24 bufo24 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

ClientConfig.timeoutMs is accepted, documented (default 30s), and resolved into ResolvedClientConfig — but never used. The GraphQLClient was constructed with only fetch and headers, no signal:

this.graphqlClient = new GraphQLClient(this.config.baseUrl, {
  fetch: this.config.fetch,
  headers: this.buildHeaders(),
});

So a hung or slow server would block a request indefinitely, and the timeoutMs option (and its default) silently did nothing.

Fix

Wrap the configured fetch so every request carries AbortSignal.timeout(timeoutMs), while honoring a caller-supplied signal if one is passed:

fetch: (input, init) =>
  fetchImpl(input, { ...init, signal: init?.signal ?? AbortSignal.timeout(timeoutMs) }),

This applies to both the gqlRequest path and the resource SDK path (getSdk(graphqlClient)), since both share the client's fetch.

Tests

Two added to client.test.ts:

  • requests carry an AbortSignal derived from timeoutMs
  • a request exceeding timeoutMs rejects

AbortSignal.timeout requires Node ≥17.3 — well within the SDK's Node ≥18.18 floor.

Note

This is a genuine fix: (touches packages/core), so it will trigger a release-please PR for @ambosstech/core.

timeoutMs was resolved and stored (default 30s) but never applied — the
GraphQLClient was constructed without any signal, so requests could hang
indefinitely. Wrap the configured fetch so every request carries an
AbortSignal.timeout(timeoutMs), honoring a caller-supplied signal when
present. Covers both gqlRequest and the resource SDK path, since both
share the client's fetch.
@bufo24
bufo24 merged commit 7fb39c0 into main Jul 7, 2026
2 checks passed
@apotdevin apotdevin mentioned this pull request Jul 7, 2026
@bufo24
bufo24 deleted the fix/apply-request-timeout branch July 7, 2026 10:41
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