Skip to content

fix: eventsource does not reconnect on network error #4247

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

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented May 30, 2025

To be honest: I am pretty much confused, why we had this regression. In #2665 the setTimeout got replaced with the non promise one, and thus broke the reconnection logic. It seems like setTimeout from timers/promise without reference, still keeps the process running, but the unref`d normal setTimeout results in letting the process die, even though we are still in reconning state.

Also I dont understand anymore why I wrote the close logic into processEventSourceEndOfBody.

So take this PR with a grain of salt.


eventSourceInstance.close()

assert.strictEqual(onerrorCalls.length, 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, defaultReconnectTime is 3000. So 1. Is about after 50-100 ms, next is 3050-3100ms and the third is at 6050-6100ms. A fourth would be after 9050-9100 ms, but we just do 7000ms (or 8000?) and so we have only 3.

@Uzlopak Uzlopak merged commit 1ec34b7 into main Jun 4, 2025
34 of 37 checks passed
@Uzlopak Uzlopak deleted the eventsource-reconnect-error branch June 4, 2025 09:44
@github-actions github-actions bot mentioned this pull request Jun 26, 2025
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

Successfully merging this pull request may close these issues.

3 participants