diff --git a/EssentialCSharp.Web/Controllers/ChatController.cs b/EssentialCSharp.Web/Controllers/ChatController.cs index 79322b08..3f803fbf 100644 --- a/EssentialCSharp.Web/Controllers/ChatController.cs +++ b/EssentialCSharp.Web/Controllers/ChatController.cs @@ -252,15 +252,12 @@ await Response.WriteAsJsonAsync(new } catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested || HttpContext.RequestAborted.IsCancellationRequested) { - // Best-effort write during an aborted request — no response body can be delivered. } catch (IOException) when (HttpContext.RequestAborted.IsCancellationRequested) { - // Expected client disconnect while attempting a best-effort error response write. } catch (ObjectDisposedException) when (HttpContext.RequestAborted.IsCancellationRequested) { - // Response stream can already be disposed after an abrupt client disconnect. } } else @@ -273,10 +270,7 @@ await Response.WriteAsJsonAsync(new } catch (Exception writeException) when (writeException is IOException or OperationCanceledException or ObjectDisposedException) { - // Best-effort write to an already-streaming response. Kestrel can throw - // IOException (connection reset), OperationCanceledException, or - // ObjectDisposedException on abrupt client disconnect — swallow expected - // transport/disconnect exceptions to avoid masking the original exception. + // Client disconnects mid-stream are expected; don't mask the original exception. } } } @@ -298,7 +292,6 @@ await Response.WriteAsJsonAsync(new } catch (Exception writeException) when (writeException is IOException or OperationCanceledException or ObjectDisposedException) { - // Best-effort write to an already-streaming response. } } catch (Exception ex) when (!Response.HasStarted) @@ -315,15 +308,12 @@ await Response.WriteAsJsonAsync(new } catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested || HttpContext.RequestAborted.IsCancellationRequested) { - // Best-effort write during an aborted request — no response body can be delivered. } catch (IOException) when (HttpContext.RequestAborted.IsCancellationRequested) { - // Expected client disconnect while attempting a best-effort error response write. } catch (ObjectDisposedException) when (HttpContext.RequestAborted.IsCancellationRequested) { - // Response stream can already be disposed after an abrupt client disconnect. } } catch (Exception ex) @@ -336,10 +326,6 @@ await Response.WriteAsJsonAsync(new } catch (Exception writeException) when (writeException is IOException or OperationCanceledException or ObjectDisposedException) { - // Best-effort write to an already-streaming response. Kestrel can throw - // IOException (connection reset), OperationCanceledException, or - // ObjectDisposedException on abrupt client disconnect — swallow expected - // transport/disconnect exceptions to avoid masking the original exception. } } } diff --git a/EssentialCSharp.Web/Services/ContentRateLimiterPolicy.cs b/EssentialCSharp.Web/Services/ContentRateLimiterPolicy.cs index 0e125c56..8b47b943 100644 --- a/EssentialCSharp.Web/Services/ContentRateLimiterPolicy.cs +++ b/EssentialCSharp.Web/Services/ContentRateLimiterPolicy.cs @@ -53,9 +53,7 @@ public RateLimitPartition GetPartition(HttpContext httpContext) } /// -/// A that acquires permits from two inner limiters in sequence. -/// Both must grant a permit for the request to proceed. If the second limiter rejects, -/// the first limiter's permit is returned so no permit is consumed. +/// Acquires from both inner limiters in sequence; a rejection by the second returns the first's permit. /// internal sealed class CombinedRateLimiter(RateLimiter perMinute, RateLimiter perHour) : RateLimiter { @@ -117,8 +115,7 @@ protected override ValueTask DisposeAsyncCore() } /// -/// A lease that holds two inner leases and disposes both on release, -/// ensuring permits are returned to both underlying limiters. +/// Holds two inner leases and disposes both on release. /// internal sealed class CombinedRateLimitLease(RateLimitLease a, RateLimitLease b) : RateLimitLease {