Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exponential reconnect backoff #57

Open
chris-aeviator opened this issue Aug 31, 2023 · 2 comments
Open

Exponential reconnect backoff #57

chris-aeviator opened this issue Aug 31, 2023 · 2 comments

Comments

@chris-aeviator
Copy link

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.

grafik

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)

@BilalTariq01
Copy link

BilalTariq01 commented Sep 4, 2023

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 #24 (comment)

@chris-aeviator
Copy link
Author

chris-aeviator commented Sep 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants