Skip to content

Commit

Permalink
Wind down the SSE thread when the client disconnects (#1514)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adaszko committed Aug 13, 2020
1 parent e6f4552 commit 05a8399
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions beacon_node/rest_api/src/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ pub fn stream_forks<T: BeaconChainTypes>(
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(_) => (),
}
}
});
Expand Down

0 comments on commit 05a8399

Please sign in to comment.