paritytech / substrate-telemetry

Polkadot Telemetry service
GNU General Public License v3.0
299 stars 208 forks source link

core: Fix noisy logs caused by closing the `/feed` browser #496

Closed lexnv closed 1 year ago

lexnv commented 1 year ago

Multiple warning messages originated from the telemetry-core' regarding flushing the WS connection.

WARN  [telemetry_core] Closing feed websocket due to error flushing data: connection closed

These errors can happen when the feed components (browsers) are closing the connection unexpectedly. This behavior can be reproduced with the following patch, added between sending and flushing the data:

--- a/backend/telemetry_core/src/main.rs
+++ b/backend/telemetry_core/src/main.rs
@@ -474,6 +474,11 @@ where
                     Ok(_) => {}
                 }
             }
+
+            log::info!("Sent bytes, will flush the feed next. Close the browser now!");
+            tokio::time::sleep(Duration::from_secs(5)).await;
+            log::info!("Finished sleeping");
+
             match tokio::time::timeout_at(message_send_deadline, ws_send.flush()).await {

To mitigate noisy logs, change the log level to debug for the cases of abruptly closing the socket.