{"record":{"id":"33f08b6b8e983894","repo":"dotnet/reactive","slug":"duration","errorCode":null,"errorMessage":"duration","messagePattern":"duration","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Skip.cs","lineNumber":37,"sourceCode":"                throw new ArgumentOutOfRangeException(nameof(count));\n\n            if (count == 0)\n            {\n                return source;\n            }\n\n            return CreateAsyncObservable<TSource>.From(\n                source,\n                count,\n                static (source, count, observer) => source.SubscribeSafeAsync(AsyncObserver.Skip(observer, count)));\n        }\n\n        public static IAsyncObservable<TSource> Skip<TSource>(this IAsyncObservable<TSource> source, TimeSpan duration)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (duration < TimeSpan.Zero)\n                throw new ArgumentOutOfRangeException(nameof(duration));\n\n            if (duration == TimeSpan.Zero)\n            {\n                return source;\n            }\n\n            // REVIEW: May be easier to just use SkipUntil with a Timer parameter. Do we want Skip on the observer?\n\n            return CreateAsyncObservable<TSource>.From(\n                source,\n                duration,\n                static async (source, duration, observer) =>\n                {\n                    var (sourceObserver, timer) = await AsyncObserver.Skip(observer, duration).ConfigureAwait(false);\n\n                    var subscription = await source.SubscribeSafeAsync(sourceObserver).ConfigureAwait(false);\n\n                    return StableCompositeAsyncDisposable.Create(subscription, timer);","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Skip.cs#L19-L55","documentation":"The TimeSpan overload Skip(source, duration) throws ArgumentOutOfRangeException with paramName \"duration\" when a negative TimeSpan is passed. A negative skip duration is meaningless, so the library rejects it eagerly.","triggerScenarios":"Calling Skip(source, TimeSpan) with a negative value, e.g. computed as deadline - now where now has passed the deadline, or from misparsed/converted time values.","commonSituations":"Computing remaining time from a deadline that already elapsed; clock skew or DateTime.UtcNow vs local time mixups; parsing durations with a sign from configuration.","solutions":["Ensure the duration is non-negative before calling Skip","Clamp with a max against TimeSpan.Zero when the value is computed (e.g. remaining time)","Fix the duration computation (use a monotonic clock or clamp at the source)"],"exampleFix":"// before\nvar remaining = deadline - DateTime.UtcNow;\nsource.Skip(remaining); // throws if deadline passed\n// after\nvar remaining = deadline - DateTime.UtcNow;\nif (remaining > TimeSpan.Zero)\n    source.Skip(remaining);","handlingStrategy":"validation","validationCode":"if (duration < TimeSpan.Zero) duration = TimeSpan.Zero;\nvar res = source.Skip(duration);","typeGuard":null,"tryCatchPattern":"try { var res = source.Skip(duration); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"duration\") { /* clamp and retry */ }","preventionTips":["Clamp computed durations against TimeSpan.Zero","Use monotonic clocks (Stopwatch) for elapsed/remaining time","Validate config-parsed durations for sign"],"tags":["argument-out-of-range","duration","rx"],"backgroundTag":"argument-out-of-range","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}