{"record":{"id":"b3b3b3197cc5287d","repo":"dotnet/reactive","slug":"actionasync","errorCode":null,"errorMessage":"actionAsync","messagePattern":"actionAsync","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/StartAsync.cs","lineNumber":72,"sourceCode":"            catch (Exception ex)\n            {\n                return Throw<TSource>(ex);\n            }\n\n            return Create<TSource>(async observer =>\n            {\n                var subscription = await task.ToAsyncObservable(scheduler).SubscribeAsync(observer).ConfigureAwait(false);\n\n                return StableCompositeAsyncDisposable.Create(cancel, subscription);\n            });\n        }\n\n        public static IAsyncObservable<Unit> StartAsync(Func<Task> actionAsync) => StartAsync(actionAsync, ImmediateAsyncScheduler.Instance);\n\n        public static IAsyncObservable<Unit> StartAsync(Func<Task> actionAsync, IAsyncScheduler scheduler)\n        {\n            if (actionAsync == null)\n                throw new ArgumentNullException(nameof(actionAsync));\n            if (scheduler == null)\n                throw new ArgumentNullException(nameof(scheduler));\n\n            Task task;\n\n            try\n            {\n                task = actionAsync();\n            }\n            catch (Exception ex)\n            {\n                return Throw<Unit>(ex);\n            }\n\n            return task.ToAsyncObservable(scheduler);\n        }\n\n        public static IAsyncObservable<Unit> StartAsync(Func<CancellationToken, Task> actionAsync) => StartAsync(actionAsync, ImmediateAsyncScheduler.Instance);","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/StartAsync.cs#L54-L90","documentation":"StartAsync(Func<Task>, IAsyncScheduler) throws ArgumentNullException when the actionAsync delegate is null. The operator invokes the delegate immediately to obtain the Task representing the work, so a null delegate is rejected during argument validation.","triggerScenarios":"Calling the Unit-returning StartAsync overload for Task-returning functions with a null Func<Task>.","commonSituations":"Unassigned async handler fields, factory/lookup returning null, refactoring that removed the actual handler.","solutions":["Pass a non-null Func<Task>","Guard the call site if the handler is optional","Initialize the delegate before invoking StartAsync"],"exampleFix":"// before\nStartAsync(handler); // handler is null\n// after\nif (handler != null) StartAsync(handler);","handlingStrategy":"validation","validationCode":"if (actionAsync == null) throw new ArgumentNullException(nameof(actionAsync));","typeGuard":"static bool IsValidActionAsync(Func<Task> f) => f is not null;","tryCatchPattern":null,"preventionTips":["Guard nullable async handlers before passing to StartAsync","Prefer initializing handlers to async no-ops over leaving them null"],"tags":["argument-null","reactive","async"],"backgroundTag":"null-argument","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"}