File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/Components/Server/src/Circuits Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -309,9 +309,20 @@ private Task PauseAndDisposeCircuitEntry(DisconnectedCircuitEntry entry)
309309
310310 private async Task PauseAndDisposeCircuitHost ( CircuitHost circuitHost , bool saveStateToClient )
311311 {
312- await _circuitPersistenceManager . PauseCircuitAsync ( circuitHost , saveStateToClient ) ;
313- circuitHost . UnhandledException -= CircuitHost_UnhandledException ;
314- await circuitHost . DisposeAsync ( ) ;
312+ try
313+ {
314+ await _circuitPersistenceManager . PauseCircuitAsync ( circuitHost , saveStateToClient ) ;
315+ }
316+ catch ( ObjectDisposedException ex )
317+ {
318+ // Expected when service provider is disposed during circuit cleanup e.g. by forced GC
319+ CircuitHost_UnhandledException ( circuitHost , new UnhandledExceptionEventArgs ( ex , isTerminating : true ) ) ;
320+ }
321+ finally
322+ {
323+ circuitHost . UnhandledException -= CircuitHost_UnhandledException ;
324+ await circuitHost . DisposeAsync ( ) ;
325+ }
315326 }
316327
317328 internal async Task PauseCircuitAsync (
You can’t perform that action at this time.
0 commit comments