Draft
Conversation
|
Azure Pipelines: 16 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: mrek-msft <188900745+mrek-msft@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
src/libraries/System.Net.ServerSentEvents/src/System/Net/ServerSentEvents/SseParserOptions.cs:28
SseParserOptions<T>.MaxBufferSizeis documented as "-1 to use the default limit", but values < -1 currently flow through and (because of the_maxBufferSize >= 0guard) effectively disable the limit. It would be safer to validate thatMaxBufferSizeis either -1 or >= 0 and throwArgumentOutOfRangeExceptionotherwise.
/// <summary>Gets the parser to use to transform each payload of bytes into a data element.</summary>
public SseItemParser<T> ItemParser { get; }
/// <summary>Gets or sets the maximum buffer size, or -1 to use the default limit.</summary>
public int MaxBufferSize { get; set; } = -1;
src/libraries/System.Net.ServerSentEvents/tests/SseParserTests.cs:34
- There’s no test coverage for invalid
MaxBufferSizevalues (e.g., < -1). Adding a focused test would ensure the new option can’t be used to silently disable buffer limiting via negative values.
[Fact]
public void Options_DefaultMaxBufferSize()
{
var options = new SseParserOptions<string>(delegate { return ""; });
Assert.Equal(-1, options.MaxBufferSize);
}
Comment on lines
15
to
+19
| /// <param name="sseStream">The stream containing the data to parse.</param> | ||
| /// <param name="itemParser">The parser to use to transform each payload of bytes into a data element.</param> | ||
| /// <param name="options">The options to use when parsing the stream.</param> | ||
| /// <returns>The enumerable, which can be enumerated synchronously or asynchronously.</returns> | ||
| /// <exception cref="ArgumentNullException"><paramref name="sseStream"/> or <paramref name="itemParser"/> is null.</exception> | ||
| public static SseParser<T> Create<T>(Stream sseStream, SseItemParser<T> itemParser) | ||
| /// <exception cref="ArgumentNullException"><paramref name="sseStream"/> or <paramref name="options"/> is null.</exception> | ||
| public static SseParser<T> Create<T>(Stream sseStream, SseParserOptions<T> options) |
Comment on lines
26
to
+30
| public static partial class SseParser | ||
| { | ||
| public const string EventTypeDefault = "message"; | ||
| public static System.Net.ServerSentEvents.SseParser<string> Create(System.IO.Stream sseStream) { throw null; } | ||
| public static System.Net.ServerSentEvents.SseParser<T> Create<T>(System.IO.Stream sseStream, System.Net.ServerSentEvents.SseItemParser<T> itemParser) { throw null; } | ||
| public static System.Net.ServerSentEvents.SseParser<T> Create<T>(System.IO.Stream sseStream, System.Net.ServerSentEvents.SseParserOptions<T> options) { throw null; } | ||
| } |
Copilot
AI
changed the title
[WIP] Add option to limit SseParser's internal buffer size
Add configurable SSE parser buffer limit
Aug 13, 2026
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SSE parsing now supports a caller-configured buffer limit through
SseParserOptions<T>.API
SseParserOptions<T>withItemParserandMaxBufferSize.MaxBufferSizeto-1by default, preserving the internal default limit.SseParser.Createoverload as the parser creation path.Coverage
Note
This description was generated by GitHub Copilot.