Skip to content

Commit

Permalink
fix not completing the writing of the JsonRPC response (#7146)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartprogrammer93 authored and kamilchodola committed Jun 6, 2024
1 parent 5a6a29f commit 19ced7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Runner/JsonRpc/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ await PushErrorResponse(StatusCodes.Status403Forbidden, ErrorCodes.InvalidReques
{
jsonSerializer.Serialize(resultWriter, result.Response);
}
await resultWriter.CompleteAsync();
if (stream is not null)
{
ctx.Response.ContentLength = resultWriter.WrittenCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace Nethermind.Serialization.Json;

public interface ICountingBufferWriter : IBufferWriter<byte>
{
public long WrittenCount { get; }
long WrittenCount { get; }
ValueTask CompleteAsync(Exception? exception = null);
}

public sealed class CountingPipeWriter : ICountingBufferWriter
Expand All @@ -42,6 +43,12 @@ public void Advance(int count)
public Memory<byte> GetMemory(int sizeHint = 0) => _writer.GetMemory(sizeHint);

public Span<byte> GetSpan(int sizeHint = 0) => _writer.GetSpan(sizeHint);

public ValueTask CompleteAsync(Exception? exception = null)
{
return _writer.CompleteAsync();
}

}

public sealed class CountingStreamPipeWriter : PipeWriter, ICountingBufferWriter
Expand Down

0 comments on commit 19ced7d

Please sign in to comment.