{"record":{"id":"4814f0998a4019df","repo":"cefsharp/CefSharp","slug":"timeout-greater-than-maximum-allowable-value-of-u","errorCode":null,"errorMessage":"Timeout greater than Maximum allowable value of {UInt32.MaxValue}","messagePattern":"Timeout greater than Maximum allowable value of (.+?)","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"CefSharp.Core/WebBrowserExtensionsEx.cs","lineNumber":205,"sourceCode":"        /// </summary>\n        /// <typeparam name=\"T\">Type</typeparam>\n        /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when one or more arguments are outside the required range.</exception>\n        /// <exception cref=\"Exception\">Thrown if a Javascript error occurs.</exception>\n        /// <param name=\"frame\">The IFrame instance this method extends.</param>\n        /// <param name=\"script\">The Javascript code that should be executed.</param>\n        /// <param name=\"timeout\">(Optional) The timeout after which the Javascript code execution should be aborted.</param>\n        /// <returns>\n        /// <see cref=\"Task{T}\"/> that can be awaited to obtain the result of the script execution. The <see cref=\"ModelBinding.DefaultBinder\"/>\n        /// is used to convert the result to the desired type. Property names are converted from camelCase.\n        /// If the script execution returns an error then an exception is thrown.\n        /// </returns>\n        public static async Task<T> EvaluateScriptAsync<T>(this IFrame frame, string script, TimeSpan? timeout = null)\n        {\n            WebBrowserExtensions.ThrowExceptionIfFrameNull(frame);\n\n            if (timeout.HasValue && timeout.Value.TotalMilliseconds > uint.MaxValue)\n            {\n                throw new ArgumentOutOfRangeException(\"timeout\", \"Timeout greater than Maximum allowable value of \" + UInt32.MaxValue);\n            }           \n\n            var response = await frame.EvaluateScriptAsync(script, timeout: timeout, useImmediatelyInvokedFuncExpression: false).ConfigureAwait(false);\n\n            if (response.Success)\n            {\n                var binder = DefaultBinder.Instance;\n\n                return (T)binder.Bind(response.Result, typeof(T));\n            }\n\n            throw new Exception(response.Message);\n        }\n\n        /// <summary>\n        /// Evaluate some Javascript code in the context of the MainFrame of the ChromiumWebBrowser. The script will be executed\n        /// asynchronously and the method returns a Task encapsulating the response from the Javascript\n        /// </summary>","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Core/WebBrowserExtensionsEx.cs#L187-L223","documentation":"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.","triggerScenarios":"Passing timeout = TimeSpan.MaxValue or a very large TimeSpan. Accidentally passing seconds as milliseconds (e.g. TimeSpan.FromSeconds(uint.MaxValue)).","commonSituations":"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).","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."],"exampleFix":"// before\nvar r = await frame.EvaluateScriptAsync<int>(script, TimeSpan.MaxValue);\n\n// after\nvar r = await frame.EvaluateScriptAsync<int>(script, timeout: null);","handlingStrategy":"validation","validationCode":"if (timeout.HasValue && timeout.Value.TotalMilliseconds > uint.MaxValue) timeout = null;\nawait frame.EvaluateScriptAsync<T>(script, timeout);","typeGuard":"public static bool IsValidTimeout(TimeSpan? t) => !t.HasValue || t.Value.TotalMilliseconds <= uint.MaxValue;","tryCatchPattern":"try { return await frame.EvaluateScriptAsync<T>(script, timeout); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"timeout\") { /* clamp and retry */ }","preventionTips":["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."],"tags":["argument-out-of-range","timeout","evaluate-script"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}