Skip to content

Release 1.0.0-alpha.10: timeoutMs is the client's rule with any Transport - #65

Merged
jallers merged 4 commits into
masterfrom
claude/client-timeout
Nov 26, 2026
Merged

jallers merged 4 commits into
masterfrom
claude/client-timeout

Conversation

@jallers

@jallers jallers commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Head 87acf90, with master merged in.

Breaking, for a consumer with its own Transport

timeoutMs now binds every transport. It was a timer inside the built-in fetch transport only. With a custom transport the client timed nothing, and a transport's own timeout was resent only if it happened to report itself as an ApiError coded TIMEOUT, which nothing said it should.

Now, per attempt, whatever the transport:

  • The client hands the transport a signal that fires after timeoutMs (default 60000) and when the caller aborts.
  • At the deadline the request rejects with TIMEOUT, whether or not the transport lets go. The client does not wait for the abort to land: the transport's promise is raced against the timer.
  • A request the client has stopped waiting for is abandoned. If its transport honours the signal, it stops; if not, it keeps the request open on its own, and whatever it answers or throws later is discarded (no unhandled rejection).
  • TIMEOUT is transient, so an idempotent request is sent once more, with a deadline of its own. A plain write is not: a timeout says the client stopped waiting, never that the server did not act.
  • timeoutMs: 0 means no timeout of the client's.
  • A transport with a shorter timeout of its own rejects first, and its error is the one the caller sees.
  • A caller's abort is ABORTED, not TIMEOUT, and is likewise not waited on.

What a transport owes is unchanged and already checked by the conformance suite: honour signal. No new check.

What changes for a consumer: requests through its transport now time out at 60 seconds by default where they waited on its HTTP client alone. An HTTP client with no timeout configured (an axios instance left at its default) now gets one. The signal a transport receives is the attempt's own, not the object the caller passed.

A transport that waits for a person inside request must set timeoutMs: 0. The deadline cannot tell a slow network from someone signing in again. An HTTP client that shows a sign-in prompt and replays the request when the user is back would see a slow sign-in end as TIMEOUT, and the replay would carry a signal that has already fired. The built-in transport is not affected: its onUnauthorized hook runs outside the deadline (tested). The doc comment on timeoutMs, the changelog's migration line, the README and spec 000 §6 say so.

Changed

  • The built-in fetch transport uses the same deadline (deadline() in src/core/retry.ts): timeoutMs: 0 means no timeout there too, and a response whose headers arrive in time but whose body stalls is a TIMEOUT (it surfaced as the runtime's own abort error).
  • examples/11-axios-transport.ts leaves timing to the client: its own mapping of axios's timeout to TIMEOUT is gone.

Fixed

  • FakeAgilityClient: a search naming a family by its abstract type (types: ["Workitem"]) is expanded to the concrete types in the request the fake records, as against a server. Found by the smoke test of the published alpha.9. Rows and fake.searched were already right.

Things a reviewer should know

  • Order of the two rules around a custom transport: withRetry(withTimeout(transport)), so each attempt has its own deadline and a resend is not cut short by the first attempt's timer.
  • The built-in transport still times and resends its own attempts (it reads Retry-After), using the shared deadline; the client does not wrap it a second time.
  • The one consumer with a custom transport reviewed this from the source only. It could not build the branch where it runs, and will run its suite, the conformance checks and its own extra transport rules against the published alpha.10. It opts out with timeoutMs: 0, because its transport waits for a person inside request (the case above); that is where the documented caveat came from.
  • No way for a custom transport to pause the deadline was added. Nobody needs it, and it would be a new duty for transports; timeoutMs: 0 is the answer today.
  • History: commit d7f8fcd is red in CI (a type error in a new test, pushed without waiting for the check); 87acf90, the next commit, fixes it.
  • Spec 000 §6 states the rule next to the resend rule. ClientConfig.timeoutMs's doc comment says what happens to the abandoned request.

Verification

  • npm run verify on 87acf90: 258 unit tests in 33 files, all passing. On a custom transport with real short timers: times out and is resent once when idempotent (the second attempt gets a fresh signal); a plain write times out and is not resent; a transport that ignores the signal still yields TIMEOUT at the deadline, and its late answer and late error are discarded with no unhandled rejection; timeoutMs: 0 waits and hands over the caller's own signal (with a control that times out); a transport's own shorter timeout wins; the caller's abort is ABORTED before sending, in flight, and against a transport that ignores it. On the built-in transport: the same deadline, a stalled body, timeoutMs: 0, and a re-authentication hook three times longer than the timeout.
  • The full integration tier against the API-testing instance ran on 1a0673b (its client runs over a custom transport, so every live request passed through the new rule): 79 passed, 3 skipped by design; fixtures deleted. After merging master, the examples suite ran again: 12 passed. The commits since change the example, documentation and one unit test.

After merge

Tag v1.0.0-alpha.10 to stage the publish.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm

Each attempt has timeoutMs whatever the transport. Above a custom
transport the client hands over a signal that fires at the deadline and
stops waiting then, whether or not the transport lets go; what an
abandoned request answers later is discarded. TIMEOUT is transient, so
an idempotent request is sent once more and a write is not. 0 is no
client timeout. The built-in transport uses the same deadline, and a
body that stalls after the headers is now a TIMEOUT.

The fake expands a type family in the search request it records.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
The example leaves timing to the client: its own timeout mapping goes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
The deadline cannot tell a person from a slow network: a custom transport
that waits for a sign-in inside request turns the client's timeout off.
The built-in transport's hook runs outside the deadline, with a test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
@jallers
jallers marked this pull request as ready for review November 26, 2026 15:57
@jallers
jallers merged commit 8677da7 into master Nov 26, 2026
4 checks passed
@jallers
jallers deleted the claude/client-timeout branch November 26, 2026 16:10
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.

2 participants