fetch-event-source
fetch-event-source copied to clipboard
Exponential reconnect backoff
When fetch-event-source loses it's connection to the server, it tries to reconnect rather aggressively. Given enough clients, this continious repeating traffic pattern may pose an unneccesary risk of overloading a router/ load balancer that might still be receiving the traffic.
This issue proposes to implement an exponential backoff behavior that increases the reconnect time with each unsuccessful reconnect iteration (see https://www.npmjs.com/package/exponential-backoff for an example implementation)
I also have the same issue but I fixed it by throwing an error from inside the onerror function.
onerror() {
// do something
throw new Error(); // hack to close the connection
}
As suggested by @jchiare in https://github.com/Azure/fetch-event-source/issues/24#issuecomment-1465768867
Thanks for sharing this. I wouldn’t want to close the connection but it’s a great place to introduce an artificial delay.
Am 04.09.2023 um 14:10 schrieb Bilal Tariq @.***>:
I also have the same issue but I fixed it by throwing an error from inside the onerror function.
onerror() { // do something throw new Error(); // hack to close the connection } — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.