Skip to content

Provide a better error message when TransportMaxBufferSize exceeded in a single message #5307

@analogrelay

Description

@analogrelay

Right now, if you send a single message that serializes to larger than 32KB, you get:

fail: Microsoft.AspNetCore.SignalR.HubConnectionHandler[2]
      Error when processing requests.
System.InvalidOperationException: Advancing examined to the end would cause pipe to deadlock because FlushAsync is waiting.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_BackpressureDeadlock()
   at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex)
   at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.DispatchMessagesAsync(HubConnectionContext connection)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)
   
   fail: Microsoft.AspNetCore.SignalR.HubConnectionHandler[2]
      Error when processing requests.
System.InvalidOperationException: Advancing examined to the end would cause pipe to deadlock because FlushAsync is waiting.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_BackpressureDeadlock()
   at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex)
   at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.DispatchMessagesAsync(HubConnectionContext connection)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)

These errors are unpleasant. They occur because we are trying to read a single message that is larger than the backpressure size. We should provide a better error message in this case (heck, even if it takes just catching the exception). Something like "Message exceeded the maximum buffer size of {TransportMaxBufferSize} bytes"

It may be difficult to do this though, so we'll need to design this a bit (and may decide it's not feasible in the process).

Metadata

Metadata

Assignees

Labels

acceptedThis issue has completed "acceptance" testing (including accessibility)area-signalrIncludes: SignalR clients and serversblockedThe work on this issue is blocked due to some dependency

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions