dotnet / dotnet/aspnetcore

Cancel response buffer copies if the client disconnects.

Open
#24,813 5 comments 0 reactions 0 assignees View on GitHub
affected-few area-mvc bug feature-mvc-razor-views Perf severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

The response body does not throw exceptions if the client disconnects. It does that to avoid noisy logs for things that weren't the server's fault. However, that means that if the app is doing something that it wants to stop early then it needs to monitor the RequestAborted token.

Example: There's no need to copy this buffer to the response if the client has disconnected. Pass RequestAborted and catch OperationCancelledException for all usages of DrainBufferAsync.
https://github.com/dotnet/aspnetcore/blob/ef1f48ab97174131f1753efe9241295b1309d3e2/src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs#L158

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.