dotnet/reactive · error · ArgumentNullException
observer
Error message
observer
What it means
AsyncObserver.IsEmpty(observer) throws ArgumentNullException with paramName "observer" when the downstream IAsyncObserver<bool> is null. It composes Any over a negated Select on the given observer and requires a valid downstream observer.
Solutions
- Pass the actual downstream observer (from SubscribeSafeAsync) into AsyncObserver.IsEmpty.
- Fix the custom observable implementation so the observer received in SubscribeAsync is forwarded, not a null field.
- Add your own ArgumentNullException guard when defining operator overloads.
Example fix
// before return source.SubscribeSafeAsync(AsyncObserver.IsEmpty(_observer)); // _observer is null // after return source.SubscribeSafeAsync(AsyncObserver.IsEmpty(observer));
Defensive patterns
Strategy: validation
Validate before calling
if (observer is null) throw new ArgumentNullException(nameof(observer)); // before calling AsyncObserver.IsEmpty<TSource>(observer)
Type guard
static bool HasObserver(IAsyncObserver<bool> o) => o is not null;
Try / catch
try { var o = AsyncObserver.IsEmpty<int>(observer); }
catch (ArgumentNullException ex) when (ex.ParamName == "observer") { /* fix observer forwarding */ } Prevention
- Forward the SubscribeAsync observer argument directly
- Avoid nullable observer fields in custom observables
- Guard observer parameters in custom operator code
When it happens
Trigger: Calling AsyncObserver.IsEmpty<TSource>(null) while authoring custom observers or wiring a custom IAsyncObservable where the downstream observer is null.
Common situations: Custom operator implementations that forget to forward the observer parameter, or custom observers holding a nullable observer field that was never assigned.
Related errors
- Value cannot be null. (Parameter 'observer')
- observer
- Value cannot be null. (Parameter 'observer')
- Value cannot be null. (Parameter 'onNextAsync')
- Value cannot be null. (Parameter 'observer')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/34df4703de3e97f6.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/IsEmpty.cs:23
namespace System.Reactive.Linq
{
public partial class AsyncObservable
{
public static IAsyncObservable<bool> IsEmpty<TSource>(this IAsyncObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
return Create<TSource, bool>(source, static (source, observer) => source.SubscribeSafeAsync(AsyncObserver.IsEmpty<TSource>(observer)));
}
}
public partial class AsyncObserver
{
public static IAsyncObserver<TSource> IsEmpty<TSource>(IAsyncObserver<bool> observer)
{
if (observer == null)
throw new ArgumentNullException(nameof(observer));
return Any<TSource>(Select<bool, bool>(observer, b => !b));
}
}
}
View on GitHub (pinned to 94b5d5ab91)