@@ -123,15 +123,15 @@ private async ValueTask WorkerAsync()
123123 // Dispose inside try/catch
124124 using var _ = envelope ;
125125
126- var ValueTask = _transport . SendEnvelopeAsync ( envelope , shutdownTimeout . Token ) ;
126+ var task = _transport . SendEnvelopeAsync ( envelope , shutdownTimeout . Token ) ;
127127
128128 _options . DiagnosticLogger ? . LogDebug (
129- "Envelope {0} in-flight to Sentry . #{1} in queue." ,
129+ "Envelope {0} handed off to transport . #{1} in queue." ,
130130 envelope . TryGetEventId ( ) ,
131131 _queue . Count
132132 ) ;
133133
134- await ValueTask . ConfigureAwait ( false ) ;
134+ await task . ConfigureAwait ( false ) ;
135135 }
136136 catch ( OperationCanceledException )
137137 {
@@ -201,7 +201,8 @@ public async ValueTask FlushAsync(TimeSpan timeout)
201201 var timeoutWithShutdown = CancellationTokenSource . CreateLinkedTokenSource (
202202 timeoutSource . Token ,
203203 _shutdownSource . Token ,
204- flushSuccessSource . Token ) ;
204+ flushSuccessSource . Token
205+ ) ;
205206
206207 var counter = 0 ;
207208 var depth = int . MaxValue ;
@@ -249,7 +250,8 @@ void EventFlushedCallback(object objProcessed, EventArgs _)
249250 {
250251 _options . DiagnosticLogger ? . LogDebug ( flushSuccessSource . IsCancellationRequested
251252 ? "Successfully flushed all events up to call to FlushAsync."
252- : "Timeout when trying to flush queue." ) ;
253+ : "Timeout when trying to flush queue."
254+ ) ;
253255 }
254256 finally
255257 {
@@ -281,6 +283,9 @@ public void Dispose()
281283 // If there's anything in the queue, it'll keep running until 'shutdownTimeout' is reached
282284 // If the queue is empty it will quit immediately
283285 _ = WorkerTask . Wait ( _options . ShutdownTimeout ) ;
286+
287+ // Dispose the transport if needed
288+ ( _transport as IDisposable ) ? . Dispose ( ) ;
284289 }
285290 catch ( OperationCanceledException )
286291 {
@@ -293,8 +298,10 @@ public void Dispose()
293298
294299 if ( _queue . Count > 0 )
295300 {
296- _options . DiagnosticLogger ? . LogWarning ( "Worker stopped while {0} were still in the queue." ,
297- _queue . Count ) ;
301+ _options . DiagnosticLogger ? . LogWarning (
302+ "Worker stopped while {0} were still in the queue." ,
303+ _queue . Count
304+ ) ;
298305 }
299306 }
300307 }
0 commit comments