Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Description

Users were unclear about how RestSharp handles Timeout values of 0, -1, and other negative values. The documentation was minimal and still referenced the obsolete MaxTimeout property.

Purpose

This pull request is a:

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Changes

Source Code (XML Documentation)

Enhanced RestClientOptions.Timeout and RestRequest.Timeout with detailed remarks explaining:

  • Default: 100 seconds when not set
  • Infinite timeout: Timeout.InfiniteTimeSpan or TimeSpan.FromMilliseconds(-1)
  • Immediate cancellation: TimeSpan.Zero
  • Invalid values: Other negative values throw ArgumentOutOfRangeException

User Documentation

configuration.md updates:

  • Replaced obsolete MaxTimeout reference with Timeout
  • Fixed typo: TImeoutTimeout
  • Added "Configuring Timeouts" section with resolution priority, behavior table, and examples

Timeout Behavior Reference

Value Behavior
null Falls back to client timeout → default (100s)
Positive TimeSpan Normal timeout after specified duration
Timeout.InfiniteTimeSpan / TimeSpan.FromMilliseconds(-1) No timeout
TimeSpan.Zero Immediate cancellation
Other negative values ArgumentOutOfRangeException

Example

// Client-level timeout
var options = new RestClientOptions("https://api.example.com") {
    Timeout = TimeSpan.FromSeconds(30)
};

// Request-level override
var request = new RestRequest("resource") {
    Timeout = TimeSpan.FromSeconds(60)
};

// Infinite timeout
var longRequest = new RestRequest("long-operation") {
    Timeout = Timeout.InfiniteTimeSpan
};

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
Original prompt

This section details on the original issue you should resolve

<issue_title>Documentation for RestClientOptions.Timeout and MaxTimeout</issue_title>
<issue_description>I know that MaxTimeout is obsolete and I should use Timeout instead, but I think this is similar to both.
I've seen that various programmers set RestClientOptions.MaxTimeout to zero or to minus one.
Is somewhere described, how RestSharp behaves in this two cases (0, -1)?
How does RestSharp behave when Timeout (I'm speaking about the new timespan) is negative?
I would like to see it somewhere described.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 12, 2025

Deploying restsharp with  Cloudflare Pages  Cloudflare Pages

Latest commit: 23739fe
Status: ✅  Deploy successful!
Preview URL: https://2fd7a1b9.restsharp.pages.dev
Branch Preview URL: https://copilot-add-documentation-fo.restsharp.pages.dev

View logs

Copilot AI changed the title [WIP] Add documentation for RestClientOptions.Timeout and MaxTimeout Document Timeout property behavior for RestClientOptions and RestRequest Dec 12, 2025
Copilot AI requested a review from alexeyzimarev December 12, 2025 17:24
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.

Documentation for RestClientOptions.Timeout and MaxTimeout

2 participants