dotnet/reactive · error · ArgumentNullException
observer
Error message
observer
What it means
AsyncObserver.Skip(observer, count) throws ArgumentNullException with paramName "observer" when the downstream observer is null. This factory builds the skip-filtering observer and requires a valid target.
Solutions
- Ensure a valid IAsyncObserver<TSource> is passed
- Fix the operator composition so the downstream observer is created before Skip
- Check test setup/mocks that return null observers
Example fix
// before var obs = AsyncObserver.Skip(downstream, 3); // downstream is null // after var downstream = AsyncObserver.Create<int>(...); var obs = AsyncObserver.Skip(downstream, 3);
Defensive patterns
Strategy: validation
Validate before calling
if (observer == null) throw new InvalidOperationException("downstream observer required");
var obs = AsyncObserver.Skip(observer, count); Type guard
bool IsValidObserver<T>(IAsyncObserver<T> o) => o != null;
Try / catch
try { var obs = AsyncObserver.Skip(downstream, count); }
catch (ArgumentNullException ex) when (ex.ParamName == "observer") { /* wire downstream before calling */ } Prevention
- Create downstream observers before composing operator factories
- Check test mocks return real observers, not null
- Validate observer arguments in custom operator helpers
When it happens
Trigger: Calling AsyncObserver.Skip(null, count), typically when a downstream observer variable was never assigned or an operator pipeline passed a null observer.
Common situations: Custom operator implementations wiring observers incorrectly; refactoring where the observer creation step was removed; mocking frameworks returning null observers in tests.
Related errors
- observer
- Value cannot be null. (Parameter 'onNext')
- Value cannot be null. (Parameter 'onError')
- Value cannot be null. (Parameter 'onCompleted')
- Value cannot be null. (Parameter 'handler')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/4210577d0ff5ee62.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Skip.cs:94
source,
(duration, scheduler),
static async (source, state, observer) =>
{
var (sourceObserver, timer) = await AsyncObserver.Skip(observer, state.duration).ConfigureAwait(false);
var subscription = await source.SubscribeSafeAsync(sourceObserver).ConfigureAwait(false);
return StableCompositeAsyncDisposable.Create(subscription, timer);
});
}
}
public partial class AsyncObserver
{
public static IAsyncObserver<TSource> Skip<TSource>(IAsyncObserver<TSource> observer, int count)
{
if (observer == null)
throw new ArgumentNullException(nameof(observer));
if (count <= 0)
throw new ArgumentOutOfRangeException(nameof(count));
return Create<TSource>(
async x =>
{
if (count == 0)
{
await observer.OnNextAsync(x).ConfigureAwait(false);
}
else
{
--count;
}
},
observer.OnErrorAsync,
observer.OnCompletedAsync
);View on GitHub (pinned to 94b5d5ab91)