Skip to content

Commit

Permalink
Document "reconnect ad-infinitum" SSE pitfall.
Browse files Browse the repository at this point in the history
  • Loading branch information
martynp authored and SergioBenitez committed Jan 18, 2024
1 parent 10b5da7 commit 61e77c5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/lib/src/response/stream/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@ impl Event {
///
/// To send messages losslessly, they must be encoded first, for instance, by
/// using [`Event::json()`].
///
/// * **Clients reconnect ad-infinitum**
///
/// The [SSE standard] stipulates: _"Clients will reconnect if the connection
/// is closed; a client can be told to stop reconnecting using the HTTP 204
/// No Content response code."_ As a result, clients will typically reconnect
/// exhaustively until either they choose to disconnect or they receive a
/// `204 No Content` response.
///
/// [SSE standard]: https://html.spec.whatwg.org/multipage/server-sent-events.html
pub struct EventStream<S> {
stream: S,
heartbeat: Option<Duration>,
Expand Down

0 comments on commit 61e77c5

Please sign in to comment.