Skip to content

[release/11.0] Use streaming serialization for JSONL entries - #134593

Merged
artl93 merged 1 commit into
release/11.0from
backport/pr-134554-to-release/11.0
Sep 25, 2026
Merged

artl93 merged 1 commit into
release/11.0from
backport/pr-134554-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #134554 to release/11.0

/cc @eiriktsarpalis

Customer Impact

  • Customer reported
  • Found internally

The newly introduced JsonSerializer.SerializeAsyncEnumerable methods were using non-streaming serialization instead of streaming serialization when handling individual JSONL elements. This resulted in the following issues:

  • Excessive buffering when streaming large elements
  • Types requiring async serialization (such as nested IAsyncEnumerable data) were not supported in these methods.

Regression

  • Yes
  • No

Testing

Added relevant testing covering the impacted scenaria.

Risk

Low. Makes a straightforward change to product code so that the streaming serialization is used instead.

The newly introduced JSONL serialization APIs weren't using streaming
serialization when serializing individual elements. This changes fixes
that issue. Should be backported to .NET 11.

Copilot-Session: 2d9038d0-a532-4707-8446-e46cbbf53858
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

@eiriktsarpalis eiriktsarpalis added the Servicing-consider Issue for next servicing release review label Sep 24, 2026
@eiriktsarpalis eiriktsarpalis added this to the 11.0.0 milestone Sep 24, 2026
@eiriktsarpalis
eiriktsarpalis requested review from artl93 and jozkee and a lite review from Copilot September 24, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The changes affect core serialization and streaming behavior across multiple APIs and warrant final human review.

Review effort: Lite
Findings: None

What changed in this PR

Backports streaming JSONL serialization improvements for large and asynchronously serialized elements.

Changes:

  • Routes Stream and PipeWriter JSONL serialization through the streaming pipeline.
  • Preserves flushing, cancellation, backpressure, and writer ownership.
  • Adds coverage for nested async enumerables, failures, metadata, and source generation.
File Description
src/​libraries/​System.Text.Json/​tests/​Common/​AsyncEnumerableTests.cs Adds coverage for streaming JSONL scenarios.
src/​libraries/​System.Text.Json/​src/​System/​Text/​Json/​Serialization/​Metadata/​JsonTypeInfoOfT.WriteHelpers.cs Supports streaming JSONL element serialization.
src/​libraries/​System.Text.Json/​src/​System/​Text/​Json/​Serialization/​Metadata/​JsonTypeInfo.cs Updates the internal serialization contract.
src/​libraries/​System.Text.Json/​src/​System/​Text/​Json/​Serialization/​JsonSerializer.Write.Stream.cs Routes stream JSONL serialization through the streaming path.
src/​libraries/​System.Text.Json/​src/​System/​Text/​Json/​Serialization/​JsonSerializer.Write.Pipe.cs Applies streaming serialization to PipeWriter JSONL entries.

@eiriktsarpalis

Copy link
Copy Markdown
Member

Approved via email.

@eiriktsarpalis eiriktsarpalis added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 24, 2026

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for me.

@artl93

artl93 commented Sep 24, 2026

Copy link
Copy Markdown
Member

@eiriktsarpalis - can you check build analysis?

@eiriktsarpalis

Copy link
Copy Markdown
Member

/ba-g test failure is unrelated

@artl93
artl93 merged commit de4c84b into release/11.0 Sep 25, 2026
100 of 105 checks passed
@artl93
artl93 deleted the backport/pr-134554-to-release/11.0 branch September 25, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Text.Json Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants