{"record":{"id":"a5f8e61e8b3fda2e","repo":"dotnet/reactive","slug":"accept-did-not-call-any-iobserver-t-method","errorCode":null,"errorMessage":"Accept did not call any IObserver<T> method","messagePattern":"Accept did not call any IObserver<T> method","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/NotificationAsyncExtensions.cs","lineNumber":48,"sourceCode":"            notification.Accept(adapter);\n            await adapter.Wait().ConfigureAwait(false);\n        }\n\n        private class NotificationAdapter<T> : IObserver<T>\n        {\n            private readonly IAsyncObserver<T> _asyncObserver;\n            private ValueTask? _valueTask;\n\n            public NotificationAdapter(IAsyncObserver<T> asyncObserver)\n            {\n                _asyncObserver = asyncObserver;\n            }\n\n            public async ValueTask Wait()\n            {\n                if (!_valueTask.HasValue)\n                {\n                    throw new InvalidOperationException(\"Accept did not call any IObserver<T> method\");\n                }\n\n                await _valueTask.Value.ConfigureAwait(false);\n            }\n\n            public void OnCompleted()\n            {\n                if (_valueTask.HasValue)\n                {\n                    throw new InvalidOperationException(\"Accept should have called only one IObserver<T> method\");\n                }\n\n                _valueTask = _asyncObserver.OnCompletedAsync();\n            }\n\n            public void OnError(Exception error)\n            {\n                if (_valueTask.HasValue)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/NotificationAsyncExtensions.cs#L30-L66","documentation":"This error comes from the Wait() helper on the ValueTask-based visitor that NotificationAsyncExtensions.AcceptAsync uses to apply an INotification to an async observer. If the visitor's OnNext/OnError/OnCompleted were never invoked when Wait() runs, the internal nullable ValueTask has no value and the code throws InvalidOperationException('Accept did not call any IObserver<T> method'). It is an internal invariant check: a well-formed notification always dispatches exactly one observer callback.","triggerScenarios":"Calling AcceptAsync on an INotification<T> implementation whose Accept never calls back into the supplied IObserver<T> — e.g. a custom/broken notification type, or accepting a notification whose visitor contract was violated by a third-party implementation.","commonSituations":"Custom INotification implementations that forget to call the visitor; library/version mismatch where a notification type predates the visitor API; hand-rolled notification mocks in tests.","solutions":["Fix the custom INotification<T> implementation so Accept invokes exactly one of OnNext/OnError/OnCompleted on the observer.","Use only the standard library notification types (Notification<T>.CreateOnNext/OnError/OnCompleted).","Update packages so notification and AsyncRx versions match.","If wrapping AcceptAsync, catch InvalidOperationException as a programming-error signal."],"exampleFix":"// before (custom notification)\npublic void Accept(IObserver<T> observer) { /* nothing called */ }\n// after\npublic void Accept(IObserver<T> observer) => observer.OnNext(_value);","handlingStrategy":"try-catch","validationCode":"if (notification is not Notification<T>) throw new InvalidOperationException(\"Only library-provided Notification<T> instances are supported by AcceptAsync\");","typeGuard":"static bool IsStandardNotification<T>(INotification<T> n) => n is Notification<T>;","tryCatchPattern":"try { await notification.AcceptAsync(asyncObserver); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Accept did not call\")) { /* notification implementation is broken — do not retry, fix the type */ }","preventionTips":["Only use Notification<T> factory methods, not custom INotification implementations","Keep System.Reactive.Async and notification sources version-aligned","In tests, avoid hand-rolled INotification mocks","Read the IObserver visitor contract before implementing custom dispatch"],"tags":["invalidoperation","notification","accept","invariant"],"backgroundTag":"internal-invariant-violation","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"}