-
Notifications
You must be signed in to change notification settings - Fork 275
Description
In the current implementation of the streamable HTTP transport, the server can consume unbounded memory.
-
stream.outgoingis a slice of messages ready to send. But they may be sent very slowly if the client connection is slow. What's worse, if the client never does a non-replay GET (and the spec says that it doesn't have to), then messages for stream 0 will never be sent. -
Since a stream can always be replayed, even after the response to a request is sent, data structures for the stream are kept forever.
For (1) and POST requests, we should bound the outgoing queue to exert backpressure on the server.
For (1) and the non-replay GET, bounding the queue will just lead to deadlock if the GET never arrives. However, dropping messages that are sent prior to receiving the GET is also wrong: it will cause a race condition where the server might send a message on a session just as it's established and before the client can make the GET request. One solution is to use a circular queue and drop old messages. These messages should be notifications for the most part (feature-changed, logging) so dropping them doesn't matter. If the server were to make requests outside of a client request, dropping those would be more problematic.