Skip to content

Commit

Permalink
Fixed websockets message corruption after cancellation (#7768)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghwan2789 authored Nov 26, 2024
1 parent 5963739 commit 98c8879
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public async ValueTask CommitAsync(
Action<SocketMessageWriter> action,
CancellationToken cancellationToken)
{
await _semaphore
.WaitAsync(cancellationToken)
.ConfigureAwait(false);

try
{
await _semaphore
.WaitAsync(cancellationToken)
.ConfigureAwait(false);

_socketMessageWriter.Reset();
action.Invoke(_socketMessageWriter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public async Task WriteObject_EmptyBuffer_ObjectParallel()
await using var writer = new SynchronizedMessageWriter(socketClient);

// act
var canceled = writer.CommitAsync(x =>
{
x.WriteStartObject();
x.WriteEndObject();
},
new(true));
Assert.True(canceled.IsCanceled);

List<Task> tasks = [];
for (var i = 0; i < 10; i++)
{
Expand Down

0 comments on commit 98c8879

Please sign in to comment.