Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 5e7bb0f

Browse files
Don't log OperationCanceledException every time an HMR client disconnects
1 parent 8396be2 commit 5e7bb0f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Microsoft.AspNetCore.SpaServices/Webpack/ConditionalProxyMiddleware.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,15 @@ private async Task<bool> PerformProxyRequest(HttpContext context)
9898

9999
using (var responseStream = await responseMessage.Content.ReadAsStreamAsync())
100100
{
101-
await responseStream.CopyToAsync(context.Response.Body, DefaultHttpBufferSize, context.RequestAborted);
101+
try
102+
{
103+
await responseStream.CopyToAsync(context.Response.Body, DefaultHttpBufferSize, context.RequestAborted);
104+
}
105+
catch (OperationCanceledException)
106+
{
107+
// The CopyToAsync task will be canceled if the client disconnects (e.g., user
108+
// closes or refreshes the browser tab). Don't treat this as an error.
109+
}
102110
}
103111

104112
return true;

0 commit comments

Comments
 (0)