Reputation: 1591
I have an endpoint that accepts text/event-stream
, it basically sends two different types of events: stats
and result
. When the server sends result
event and closes the connection.
The problem is that the browser retries the connection because of the sse's design. In order to prevent that, I set retry value to a higher number such as 60000 and close the connection in client when it gets the result.
The problem is that Chrome sends multiple requests to the server if the latency is high (it works without an issue on localhost). Safari and Firefox works without an issue. In Chrome, there's only one request on networks tab so I don't think that Chrome tries to connect the server because the request timeouts. It also doesn't wait the server to close first request because sending the second request. What might cause this issue in Chrome?
Note: The endpoint of the server-sent request and the origin is different. For normal HTTP requests Chrome additionally sends OPTIONS request in order to find out the permissions but for SSE it doesn't send OPTIONS preflight request but I'm not sure this is a problem since SSE is a GET request.
Upvotes: 3
Views: 1466
Reputation: 1591
The issue is caused by Google Data Saver extension. I didn't check if the request is coming from Google's servers or is it just the browser that fires the same request again but disabling that extension solved the issue.
Upvotes: 0