dotnet / dotnet/aspnetcore

Potential out of memory with slow SignalR clients

Open
#44,943 1 comment 0 reactions 0 assignees View on GitHub
area-signalr
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

I noticed the SignalR client connection receive loop uses an unbounded receive buffer [here](https://github.com/dotnet/aspnetcore/blob/4c300ec6db7117a05b7c79cf6f617e9d498212b6/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs#L1273). If I read the code correctly it looks like network backpressure is not applied in the opposite direction - from the runtime into the receive loop. In theory, if an app is very slow to process the received messages, it is entirely possible for the `invocationMessageChannel` to grow until the application runs out of memory.

Can the code be refactored to use a bounded channel instead, with a configurable maximum size?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.