Description
We currently dispose the backpressure monitor here:
|
_backpressureMonitor?.Dispose(); |
That gets passed into the Client:
|
client ??= new SentryClient(options, randomValuesFactory: _randomValuesFactory, sessionManager: _sessionManager, backpressureMonitor: _backpressureMonitor); |
... and thus eventually into the Transport:
|
var transport = _options.Transport ?? new LazyHttpTransport(_options, _backpressureMonitor); |
However we intentionally leave the client dangling when we dispose of the Hub... so that it can continue to receive requests from things that are wrapping up during application shutdown.
But if the Client and the Transport don't get disposed of when the Hub is, that could result in an ObjectDisposedException here:
|
var downsampledRate = sampleRate * _backpressureMonitor.GetDownsampleFactor(); |
Instead, we should maybe tell the worker task to exit by cancelling it's token and then just let the backpressure monitor dangle and hang out with the client until GC decides to nuke them.
Description
We currently dispose the backpressure monitor here:
sentry-dotnet/src/Sentry/Internal/Hub.cs
Line 873 in 04c932b
That gets passed into the Client:
sentry-dotnet/src/Sentry/Internal/Hub.cs
Line 71 in 04c932b
... and thus eventually into the Transport:
sentry-dotnet/src/Sentry/Internal/SdkComposer.cs
Line 28 in 9e2f5f2
However we intentionally leave the client dangling when we dispose of the Hub... so that it can continue to receive requests from things that are wrapping up during application shutdown.
But if the Client and the Transport don't get disposed of when the Hub is, that could result in an
ObjectDisposedExceptionhere:sentry-dotnet/src/Sentry/SentryClient.cs
Line 381 in fc117ae
Instead, we should maybe tell the worker task to exit by cancelling it's token and then just let the backpressure monitor dangle and hang out with the client until GC decides to nuke them.