From 05a8399769df61962b73f606b80c232f1f4f2e47 Mon Sep 17 00:00:00 2001 From: Adam Szkoda Date: Thu, 13 Aug 2020 06:12:18 +0000 Subject: [PATCH] Wind down the SSE thread when the client disconnects (#1514) These started to appear when I `^C` `curl -N http://localhost:5052/beacon/fork/stream`: `Aug 12 13:00:01.539 ERRO Couldn't stream piece hyper::Error(ChannelClosed), service: http` Something must have changed in hyper since SSE has been implemented because I'm sure I haven't seen those errors before. This PR properly detects a closed SSE stream and cleans up. --- beacon_node/rest_api/src/beacon.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beacon_node/rest_api/src/beacon.rs b/beacon_node/rest_api/src/beacon.rs index 73c6bd1ea..f7887c48f 100644 --- a/beacon_node/rest_api/src/beacon.rs +++ b/beacon_node/rest_api/src/beacon.rs @@ -155,8 +155,10 @@ pub fn stream_forks( break; } }; - if let Err(bytes) = block_on(sender.send_data(chunk)) { - error!(log, "Couldn't stream piece {:?}", bytes); + match block_on(sender.send_data(chunk)) { + Err(e) if e.is_closed() => break, + Err(e) => error!(log, "Couldn't stream piece {:?}", e), + Ok(_) => (), } } });