{"record":{"id":"ee416482386513e1","repo":"dotnet/reactive","slug":"throw-new-argumentnullexception-nameof-firsttimeout","errorCode":null,"errorMessage":"throw new ArgumentNullException(nameof(firstTimeout));","messagePattern":"throw new ArgumentNullException\\(nameof\\(firstTimeout\\)\\);","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs","lineNumber":1961,"sourceCode":"        /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence.</typeparam>\n        /// <typeparam name=\"TTimeout\">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to perform a timeout for.</param>\n        /// <param name=\"firstTimeout\">Observable sequence that represents the timeout for the first element.</param>\n        /// <param name=\"timeoutDurationSelector\">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>\n        /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"firstTimeout\"/> or <paramref name=\"timeoutDurationSelector\"/> is null.</exception>\n        public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            if (firstTimeout == null)\n            {\n                throw new ArgumentNullException(nameof(firstTimeout));\n            }\n\n            if (timeoutDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(timeoutDurationSelector));\n            }\n\n            return s_impl.Timeout(source, firstTimeout, timeoutDurationSelector);\n        }\n\n        /// <summary>\n        /// Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element.\n        /// If the next element isn't received within the computed duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>\n        /// <typeparam name=\"TTimeout\">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to perform a timeout for.</param>\n        /// <param name=\"firstTimeout\">Observable sequence that represents the timeout for the first element.</param>","sourceCodeStart":1943,"sourceCodeEnd":1979,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs#L1943-L1979","documentation":"The Timeout(source, firstTimeout, timeoutDurationSelector) overload throws ArgumentNullException because the firstTimeout sequence is null. firstTimeout defines the timeout window for the very first element and is a required stream. Validation happens eagerly before the query is returned.","triggerScenarios":"Calling source.Timeout(firstTimeout, selector) with a null IObservable<TTimeout> first-timeout stream.","commonSituations":"A lazily created warm-up timeout stream that was never assigned; a merged stream expression evaluating to null; config that gates creation of the first-timeout stream.","solutions":["Pass a real first-timeout stream, e.g. Observable.Timer(TimeSpan.FromSeconds(5))","If there is no initial timeout, use the (source, selector) overload instead","Null-check firstTimeout before composing the query"],"exampleFix":"// before\nsource.Timeout(firstTimeout, selector)\n// after\nvar ft = firstTimeout ?? Observable.Timer(TimeSpan.FromSeconds(5));\nsource.Timeout(ft, selector)","handlingStrategy":"validation","validationCode":"var ft = firstTimeout ?? Observable.Timer(TimeSpan.FromSeconds(5));\nvar result = source.Timeout(ft, timeoutDurationSelector);","typeGuard":"static bool IsNonNullStream<T>(IObservable<T> s) => s is not null;","tryCatchPattern":"try\n{\n    result = source.Timeout(firstTimeout, selector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"firstTimeout\")\n{\n    result = source.Timeout(selector); // no initial timeout window\n}","preventionTips":["Create first-timeout streams eagerly (Observable.Timer) rather than lazily","Use the selector-only overload when there is no initial timeout","Null-check combined stream expressions before passing them"],"tags":["argumentnull","reactive-extensions","timeout-stream","argument-validation"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}