Skip to content

feat(api): add request options for timeout and abort signal#1871

Merged
ryanio merged 2 commits intomainfrom
feat/post-request-options
Jan 15, 2026
Merged

feat(api): add request options for timeout and abort signal#1871
ryanio merged 2 commits intomainfrom
feat/post-request-options

Conversation

@ryanio
Copy link
Collaborator

@ryanio ryanio commented Jan 15, 2026

Summary

Adds support for request-level options in the post() method, addressing the use case from #1868 with a clean, typed interface.

New Features

RequestOptions interface:

interface RequestOptions {
  /** Request timeout in milliseconds */
  timeout?: number;
  /** AbortController signal for request cancellation */
  signal?: AbortSignal;
}

Usage examples:

// Set a 5 second timeout
await api.post('/path', body, headers, { timeout: 5000 });

// Use AbortController for cancellation
const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);
await api.post('/path', body, headers, { signal: controller.signal });

Use Cases

This enables:

  • Abort/timeout control via AbortController - Avoid requests hanging indefinitely in CI, server-side batch scripts, or when the API is slow
  • Custom timeout settings per request - Override default timeouts for specific operations

Changes

  • Added RequestOptions interface to src/types.ts
  • Updated post() method to accept optional options parameter
  • Updated Fetcher interface for consistency
  • Added tests for timeout and abort signal functionality

Related

Addresses the feedback from @kinderjoypresents on #1868 - this provides a proper typed interface for request options instead of the heuristic-based approach.

🤖 Generated with Claude Code

Add support for request-level options in post() method:
- timeout: Set request timeout in milliseconds
- signal: Pass AbortController signal for request cancellation

This enables:
- Abort/timeout control via AbortController (useful for CI, batch scripts)
- Custom timeout settings per request

The new RequestOptions interface is exported for SDK consumers.

Closes the use case from #1868 with a clean, typed interface instead
of heuristics.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Extend RequestOptions support to get() for consistency with post().
Same timeout and abort signal options now available for GET requests.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ryanio ryanio merged commit 07b2488 into main Jan 15, 2026
7 of 8 checks passed
@ryanio ryanio deleted the feat/post-request-options branch January 15, 2026 18:52
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