No timeout for API events (#10611)

* no event timeout

* Revert "Auxiliary commit to revert individual files from 1bfe8327ed02104432cc6bde09ac6afc8fb21f62"

This reverts commit 5f7aa10e5bc0bc18a414efdf425ae90cbcf08b99.

* proper solution

* comment fix

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka 2022-05-03 19:42:06 +02:00 committed by GitHub
parent d4fa490dec
commit 1d587c0e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,6 +186,7 @@ func writeSSZResponseHeaderAndBody(grpcResp *http.Response, w http.ResponseWrite
func handleEvents(m *apimiddleware.ApiProxyMiddleware, _ apimiddleware.Endpoint, w http.ResponseWriter, req *http.Request) (handled bool) {
sseClient := sse.NewClient("http://" + m.GatewayAddress + "/internal" + req.URL.RequestURI())
sseClient.Headers["Grpc-Timeout"] = "0S"
eventChan := make(chan *sse.Event)
// We use grpc-gateway as the server side of events, not the sse library.
@ -212,8 +213,8 @@ func receiveEvents(eventChan <-chan *sse.Event, w http.ResponseWriter, req *http
case msg := <-eventChan:
var data interface{}
// The message's event comes to us with trailing whitespace. Remove it here for
// ease of future procesing.
// The message's event comes to us with trailing whitespace. Remove it here for
// ease of future processing.
msg.Event = bytes.TrimSpace(msg.Event)
switch string(msg.Event) {