dotnet/reactive · error · ArgumentNullException
Value cannot be null. (Parameter 'windowBoundaries')
Error message
Value cannot be null. (Parameter 'windowBoundaries')
What it means
The Window(source, windowBoundaries) overload throws ArgumentNullException when the windowBoundaries observable is null (runtime message names parameter 'windowBoundaries'). Window openings are driven by emissions from the boundary observable, so null is invalid and rejected before the operator is created.
Solutions
- Create a real boundary observable (e.g. timer-based) before calling Window.
- Substitute AsyncObservable.Empty<TWindowBoundary>() when boundaries are intentionally absent.
- Fix the factory producing windowBoundaries so it never returns null.
- Guard: if (windowBoundaries == null) throw with a clear message at pipeline setup.
Example fix
// before var windows = events.Window(boundaries); // boundaries == null // after var boundaries = boundariesFactory ?? AsyncObservable.Empty<long>(); var windows = events.Window(boundaries);
Defensive patterns
Strategy: validation
Validate before calling
if (windowBoundaries is null) throw new ArgumentNullException(nameof(windowBoundaries)); var windows = source.Window(windowBoundaries);
Type guard
static bool HasBoundaries<TSource, B>(IAsyncObservable<TSource> source, IAsyncObservable<B>? boundaries) => boundaries is not null;
Try / catch
try { var windows = source.Window(boundaries); }
catch (ArgumentNullException ex) when (ex.ParamName == "windowBoundaries") { /* fall back to time-based Window overload */ } Prevention
- Substitute AsyncObservable.Empty<B>() when the boundary stream is disabled
- Ensure boundary/timer factories cannot return null
- Validate both arguments at the pipeline-composition layer
When it happens
Trigger: Calling source.Window(windowBoundaries) with a null boundary observable — e.g. a boundaries factory returning null, or a variable assigned conditionally.
Common situations: A 'tick source' or timer pipeline that failed to initialize; mocking a boundary observable and returning null; configuration that disables the boundary stream without substituting an empty one.
Related errors
- Value cannot be null. (Parameter 'source')
- Value cannot be null. (Parameter 'windowClosingSelector')
- Value cannot be null. (Parameter 'observer')
- Value cannot be null. (Parameter 'subscription')
- nameof(finallyAction)
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/01593fe5dc8d0f02.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Window.cs:141
if (timeSpan < TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(timeSpan));
if (count <= 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (scheduler == null)
throw new ArgumentNullException(nameof(scheduler));
return CreateAsyncObservable<IAsyncObservable<TSource>>.From(
source,
(timeSpan, count, scheduler),
static (source, state, observer) => WindowAsyncCore(source, observer, (o, d) => AsyncObserver.Window(o, d, state.timeSpan, state.count, state.scheduler)));
}
public static IAsyncObservable<IAsyncObservable<TSource>> Window<TSource, TWindowBoundary>(this IAsyncObservable<TSource> source, IAsyncObservable<TWindowBoundary> windowBoundaries)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (windowBoundaries == null)
throw new ArgumentNullException(nameof(windowBoundaries));
return CreateAsyncObservable<IAsyncObservable<TSource>>.From(
source,
windowBoundaries,
static async (source, windowBoundaries, observer) =>
{
var d = new CompositeAsyncDisposable();
var (sourceObserver, boundariesObserver, subscription) = await AsyncObserver.Window<TSource, TWindowBoundary>(observer, d).ConfigureAwait(false);
var sourceSubscription = await source.SubscribeSafeAsync(sourceObserver).ConfigureAwait(false);
await d.AddAsync(sourceSubscription).ConfigureAwait(false);
var boundariesSubscription = await windowBoundaries.SubscribeSafeAsync(boundariesObserver).ConfigureAwait(false);
await d.AddAsync(boundariesSubscription).ConfigureAwait(false);
return subscription;
});View on GitHub (pinned to 94b5d5ab91)