From 61e77c5e139bec2d0658caf9a07069bda6ec2373 Mon Sep 17 00:00:00 2001 From: Martyn Date: Wed, 6 Dec 2023 21:57:06 +0000 Subject: [PATCH] Document "reconnect ad-infinitum" SSE pitfall. --- core/lib/src/response/stream/sse.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/lib/src/response/stream/sse.rs b/core/lib/src/response/stream/sse.rs index ae2445795f..27044e27af 100644 --- a/core/lib/src/response/stream/sse.rs +++ b/core/lib/src/response/stream/sse.rs @@ -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 { stream: S, heartbeat: Option,