You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actions returning IAsyncEnumerable<> are no longer buffered by MVC when using System.Text.Json
In 5.0, MVC added support for output formatting IAsyncEnumerable<> types by buffering the sequence in memory and formatting the buffered collection. In 6.0, when formatting using System.Text.Json, IAsyncEnumerable<> instances are no longer buffered by MVC, instead relying on the support for these types added to System.Text.Json.
In most cases, the absence of buffering would not be observed by the application. However, some scenarios may have inadvertently relied on the buffering semantics to correctly serialize. For instance, returning an IAsyncEnumerable<> that is backed by a EF query on a type with lazy loaded properties might result in concurrent query execution which might be unsupported by the provider.
This change does not affect output formatting using Newtonsoft.Json, or with XML-based formatters
Version introduced
6.0-preview4
Old behavior
IAsyncEnumerable<> instances returned from an MVC action as a value to be formatted using ObjectResult, or a JsonResult would be buffered before being serialized as synchronous collection.
New behavior
When formatting using System.Text.Json, IAsyncEnumerable<> instances are no longer buffered by MVC.
Reason for change
System.Text.Json added support for streaming IAsyncEnumerable<> types. This allows for a smaller memory footprint during serialization.
Recommended action
If your application requires buffering, consider manually buffering the async enumerable:
Actions returning IAsyncEnumerable<> are no longer buffered by MVC when using System.Text.Json
In 5.0, MVC added support for output formatting
IAsyncEnumerable<>
types by buffering the sequence in memory and formatting the buffered collection. In 6.0, when formatting using System.Text.Json,IAsyncEnumerable<>
instances are no longer buffered by MVC, instead relying on the support for these types added to System.Text.Json.In most cases, the absence of buffering would not be observed by the application. However, some scenarios may have inadvertently relied on the buffering semantics to correctly serialize. For instance, returning an
IAsyncEnumerable<>
that is backed by a EF query on a type with lazy loaded properties might result in concurrent query execution which might be unsupported by the provider.This change does not affect output formatting using Newtonsoft.Json, or with XML-based formatters
Version introduced
6.0-preview4
Old behavior
IAsyncEnumerable<>
instances returned from an MVC action as a value to be formatted usingObjectResult
, or aJsonResult
would be buffered before being serialized as synchronous collection.New behavior
When formatting using System.Text.Json,
IAsyncEnumerable<>
instances are no longer buffered by MVC.Reason for change
System.Text.Json added support for streaming
IAsyncEnumerable<>
types. This allows for a smaller memory footprint during serialization.Recommended action
If your application requires buffering, consider manually buffering the async enumerable:
Category
ASP.NET
Affected APIs
"Not detectable via API analysis"
Issue metadata
The text was updated successfully, but these errors were encountered: