cefsharp/CefSharp · error · ArgumentOutOfRangeException
Timeout greater than Maximum allowable value of {UInt32.MaxV
Error message
Timeout greater than Maximum allowable value of {UInt32.MaxValue} What it means
Thrown by EvaluateScriptAsync<T> when the supplied timeout exceeds uint.MaxValue milliseconds (~49.7 days). The timeout is forwarded to CEF which stores it as an unsigned 32-bit millisecond value, so a larger TimeSpan would overflow the native type. The guard catches the overflow before it reaches CEF.
Source
Thrown at CefSharp.Core/WebBrowserExtensionsEx.cs:205
/// </summary>
/// <typeparam name="T">Type</typeparam>
/// <exception cref="ArgumentOutOfRangeException">Thrown when one or more arguments are outside the required range.</exception>
/// <exception cref="Exception">Thrown if a Javascript error occurs.</exception>
/// <param name="frame">The IFrame instance this method extends.</param>
/// <param name="script">The Javascript code that should be executed.</param>
/// <param name="timeout">(Optional) The timeout after which the Javascript code execution should be aborted.</param>
/// <returns>
/// <see cref="Task{T}"/> that can be awaited to obtain the result of the script execution. The <see cref="ModelBinding.DefaultBinder"/>
/// is used to convert the result to the desired type. Property names are converted from camelCase.
/// If the script execution returns an error then an exception is thrown.
/// </returns>
public static async Task<T> EvaluateScriptAsync<T>(this IFrame frame, string script, TimeSpan? timeout = null)
{
WebBrowserExtensions.ThrowExceptionIfFrameNull(frame);
if (timeout.HasValue && timeout.Value.TotalMilliseconds > uint.MaxValue)
{
throw new ArgumentOutOfRangeException("timeout", "Timeout greater than Maximum allowable value of " + UInt32.MaxValue);
}
var response = await frame.EvaluateScriptAsync(script, timeout: timeout, useImmediatelyInvokedFuncExpression: false).ConfigureAwait(false);
if (response.Success)
{
var binder = DefaultBinder.Instance;
return (T)binder.Bind(response.Result, typeof(T));
}
throw new Exception(response.Message);
}
/// <summary>
/// Evaluate some Javascript code in the context of the MainFrame of the ChromiumWebBrowser. The script will be executed
/// asynchronously and the method returns a Task encapsulating the response from the Javascript
/// </summary>View on GitHub (pinned to 16bc6e0711)
Solutions
- Pass timeout: null to use CEF's default (unbounded) timeout instead of a large TimeSpan.
- Cap the timeout at uint.MaxValue milliseconds explicitly if you must pass a value.
- Double-check units: the parameter is a TimeSpan converted to TotalMilliseconds.
Example fix
// before var r = await frame.EvaluateScriptAsync<int>(script, TimeSpan.MaxValue); // after var r = await frame.EvaluateScriptAsync<int>(script, timeout: null);
Defensive patterns
Strategy: validation
Validate before calling
if (timeout.HasValue && timeout.Value.TotalMilliseconds > uint.MaxValue) timeout = null; await frame.EvaluateScriptAsync<T>(script, timeout);
Type guard
public static bool IsValidTimeout(TimeSpan? t) => !t.HasValue || t.Value.TotalMilliseconds <= uint.MaxValue;
Try / catch
try { return await frame.EvaluateScriptAsync<T>(script, timeout); }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "timeout") { /* clamp and retry */ } Prevention
- Pass null for an unbounded timeout rather than TimeSpan.MaxValue.
- Validate TimeSpan against uint.MaxValue milliseconds before passing.
- Be explicit about units — the value is converted to milliseconds.
When it happens
Trigger: Passing timeout = TimeSpan.MaxValue or a very large TimeSpan. Accidentally passing seconds as milliseconds (e.g. TimeSpan.FromSeconds(uint.MaxValue)).
Common situations: Developers using TimeSpan.FromDays with large values, or defaulting to TimeSpan.MaxValue meaning 'no timeout' — use null instead for an unbounded wait. Confusing units (ticks vs ms vs seconds).
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/4814f0998a4019df.
Report an issue: GitHub.