Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions EssentialCSharp.Web/Controllers/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
}
}
}
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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.
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions EssentialCSharp.Web/Services/ContentRateLimiterPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public RateLimitPartition<string> GetPartition(HttpContext httpContext)
}

/// <summary>
/// A <see cref="RateLimiter"/> 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.
/// </summary>
internal sealed class CombinedRateLimiter(RateLimiter perMinute, RateLimiter perHour) : RateLimiter
{
Expand Down Expand Up @@ -117,8 +115,7 @@ protected override ValueTask DisposeAsyncCore()
}

/// <summary>
/// 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.
/// </summary>
internal sealed class CombinedRateLimitLease(RateLimitLease a, RateLimitLease b) : RateLimitLease
{
Expand Down
Loading