dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

ObjectDisposedException in AppBuilderExtensions #273

Closed OracPrime closed 3 years ago

OracPrime commented 3 years ago

There is a catch clause in AppBuilderExtensions.cs:

            catch (ObjectDisposedException)
            {
               // There's a chance the scoped service provider is already disposed when we get to here, so fall back to global provider.
               return ActivatorUtilities.CreateInstance(provider, type, args ?? new object[] { });
            }

This seems to be happening all the time for me - which clearly I can ignore, but I wonder if it is a symptom of something else. In particular it seems to go off when a Reactive property Subscribe target is called. The property is set up in the constructor

AddProperty<IReadOnlyCollection<long>>("CpuHistory", Array.Empty<long>()).SubscribeTo(cluster.CpuHistoryStream).Subscribe(_ => PushUpdates());

And within the PushUpdates the error occurs. Am I doing something wrong, or is this an area where the code needs to be improved, or is it a "live with it" scenario?

Thanks.

dsuryd commented 3 years ago

The exception typically happens when the view is closed on the client while the server is in the process of pushing updates. Does this describe your situation? In any case, it's indeed an area where the code can be improved.

OracPrime commented 3 years ago

No - I don't believe I have any view closures. This is one browser, one app, clean start to stable.

dsuryd commented 3 years ago

Fixed in v5.0.