You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
For (possibly infinite) SSE streams, when client disconnects (ex. closes connection), hyper connection always returns error of type hyper::Error(IncompleteMessage).
I tried this code:
I used server example from official website + tokio IntervalStream for body:
Have you been able to take a look at what triggers the error? My guess is that since the response isn't complete (because you can still stream more events to the client), when hyper notices the connection closed and determines it needs to tell you about the potential error condition (that the client didn't see all of the response). hyper has no special handling of server-sent-events, as they aren't actually special in the HTTP spec: they are just a long lived streaming response.
Thus, it's not immediately clear how hyper would know whether this is an error, or should be ignored. Suggestions are weclome. But also, since the application knows better what kind of streaming it is doing, it can choose to ignore these errors.
My guess is that since the response isn't complete (because you can still stream more events to the client), when hyper notices the connection closed and determines it needs to tell you about the potential error condition (that the client didn't see all of the response)
IIRC this is exactly the case.
Probably to handle this correctly, Body should be aware if its finite or not. Maybe it should be separate method like is_finite_stream or maybe a special case of size_hint? But this makes interface more complicated, especially for typical case.
Also maybe something a bit less correct, but easier to implement would be to check what poll_frame returned, and if it's Pending (eg. no more body available at the moment) the error could be suppressed?
Version
1.4.1 full
Platform
windows 11 64b
Description
For (possibly infinite) SSE streams, when client disconnects (ex. closes connection), hyper connection always returns error of type
hyper::Error(IncompleteMessage)
.I tried this code:
I used server example from official website + tokio IntervalStream for body:
I expected to see this happen:
serve_connection
shouldn't return Err on client disconnect. Ok should be returned and stream dropped.Instead, this happened: Error of type
hyper::Error(IncompleteMessage)
is returned.The text was updated successfully, but these errors were encountered: