{"record":{"id":"3ec42fc82e903d0e","repo":"dotnet/reactive","slug":"scheduler-startasync","errorCode":null,"errorMessage":"scheduler","messagePattern":"scheduler","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/StartAsync.cs","lineNumber":21,"sourceCode":"// See the LICENSE file in the project root for more information. \n\nusing System.Reactive.Concurrency;\nusing System.Reactive.Disposables;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<TSource> StartAsync<TSource>(Func<ValueTask<TSource>> functionAsync) => StartAsync(functionAsync, ImmediateAsyncScheduler.Instance);\n\n        public static IAsyncObservable<TSource> StartAsync<TSource>(Func<ValueTask<TSource>> functionAsync, IAsyncScheduler scheduler)\n        {\n            if (functionAsync == null)\n                throw new ArgumentNullException(nameof(functionAsync));\n            if (scheduler == null)\n                throw new ArgumentNullException(nameof(scheduler));\n\n            Task<TSource> task;\n\n            try\n            {\n                task = functionAsync().AsTask();\n            }\n            catch (Exception ex)\n            {\n                return Throw<TSource>(ex);\n            }\n\n            return task.ToAsyncObservable(scheduler);\n        }\n\n        public static IAsyncObservable<TSource> StartAsync<TSource>(Func<CancellationToken, ValueTask<TSource>> functionAsync) => StartAsync(functionAsync, ImmediateAsyncScheduler.Instance);\n\n        public static IAsyncObservable<TSource> StartAsync<TSource>(Func<CancellationToken, ValueTask<TSource>> functionAsync, IAsyncScheduler scheduler)","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/StartAsync.cs#L3-L39","documentation":"StartAsync<TSource>(Func<ValueTask<TSource>>, IAsyncScheduler) throws ArgumentNullException when the scheduler parameter is null. The scheduler governs where the async work runs; the library requires an explicit instance rather than treating null as 'immediate'.","triggerScenarios":"Calling StartAsync(functionAsync, null) with a valid function but a null IAsyncScheduler.","commonSituations":"Unconfigured scheduler dependency, tests passing null, copy-paste from code that used the overload without a scheduler.","solutions":["Supply a real scheduler, e.g. ImmediateAsyncScheduler.Instance","Use the single-argument overload StartAsync(functionAsync) which defaults to ImmediateAsyncScheduler.Instance","Repair the configuration that yielded a null scheduler"],"exampleFix":"// before\nStartAsync(fetch, null);\n// after\nStartAsync(fetch, ImmediateAsyncScheduler.Instance);","handlingStrategy":"validation","validationCode":"if (scheduler == null) scheduler = ImmediateAsyncScheduler.Instance; // or choose the 1-arg overload","typeGuard":"static bool IsValidScheduler(IAsyncScheduler s) => s is not null;","tryCatchPattern":null,"preventionTips":["Default to ImmediateAsyncScheduler.Instance when no scheduler is configured","Centralize scheduler resolution in one non-null-returning provider"],"tags":["argument-null","scheduler","reactive"],"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"}