dotnet/reactive · error · ArgumentNullException
action
Error message
action
What it means
Start(Action) throws ArgumentNullException when the action delegate passed to it is null. The library validates arguments eagerly so the failure surfaces at subscription-setup time rather than later inside the reactive pipeline. Since Start wraps the delegate in ToAsync, a null delegate cannot be meaningfully executed.
Solutions
- Ensure a non-null Action delegate is passed to Start(action)
- If the delegate may be absent, guard the call site before invoking Start
- Check why the delegate source (field, factory, dictionary lookup) produced null
Example fix
// before
Action work = GetHandler(); // may be null
var xs = Start(work);
// after
Action work = GetHandler() ?? (() => { });
var xs = Start(work); Defensive patterns
Strategy: validation
Validate before calling
if (action == null) throw new ArgumentNullException(nameof(action)); // or guard before calling Start
Type guard
static bool IsValidAction(Action a) => a is not null;
Prevention
- Never pass nullable delegate fields directly to Start
- Default-initialize delegates with no-op lambdas
- Assert delegate non-nullness in unit tests
When it happens
Trigger: Calling System.Reactive.Async Linq Operators.Start with a null Action, e.g. a delegate variable that was never assigned or a method group that resolved to null.
Common situations: Conditionally assigned delegates, refactored code where a callback field is no longer initialized, passing a result of a factory/lookup that returned null.
Related errors
- null (Parameter 'scheduler')
- null (Parameter 'values')
- functionAsync
- actionAsync
- Value cannot be null. (Parameter 'onErrorAsync')
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/dfe153663ef556ca.
Report an issue: GitHub.
Appendix: source
Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Start.cs:32
throw new ArgumentNullException(nameof(function));
return ToAsync(function)();
}
public static IAsyncObservable<TSource> Start<TSource>(Func<TSource> function, IAsyncScheduler scheduler)
{
if (function == null)
throw new ArgumentNullException(nameof(function));
if (scheduler == null)
throw new ArgumentNullException(nameof(scheduler));
return ToAsync(function, scheduler)();
}
public static IAsyncObservable<Unit> Start(Action action)
{
if (action == null)
throw new ArgumentNullException(nameof(action));
return ToAsync(action)();
}
public static IAsyncObservable<Unit> Start(Action action, IAsyncScheduler scheduler)
{
if (action == null)
throw new ArgumentNullException(nameof(action));
if (scheduler == null)
throw new ArgumentNullException(nameof(scheduler));
return ToAsync(action, scheduler)();
}
}
}
View on GitHub (pinned to 94b5d5ab91)