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

Fix reconnect loop #115

Merged
merged 4 commits into from
Sep 13, 2024
Merged

Fix reconnect loop #115

merged 4 commits into from
Sep 13, 2024

Conversation

jkhsjdhjs
Copy link

The close listener is called when the socket is destroyed, which initiates another reconnect attempt. This reconnect attempt disconnects the new connection created by this control flow after the retryDelay. To avoid an endless reconnect loop, we need to remove the close listener here before destroying the socket.

Fix #96

@jkhsjdhjs jkhsjdhjs requested a review from a team as a code owner July 24, 2024 23:50
Copy link

@tadzik tadzik left a comment

Choose a reason for hiding this comment

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

Looks good, and makes sense.

I wonder if we should just unbind all event listeners while we're here, like we do in our destory(), just to be on the safe side?

The 'close' listener is called when the socket is destroyed, which
initiates another reconnect attempt. This reconnect attempt disconnects
the new connection created by this control flow after the `retryDelay`.
To avoid an endless reconnect loop, we need to remove the 'close'
listener here before destroying the socket.

Fix matrix-org#96
Signed-off-by: jkhsjdhjs <leon.moeller@yahoo.de>
@jkhsjdhjs
Copy link
Author

I guess it can't hurt and it also makes the code a bit prettier, as we can move the unbinding of the listeners to a separate function. Did so in 5377bd5

@tadzik
Copy link

tadzik commented Sep 13, 2024

Perfect. Sorry for having this sit for long – thanks for the ping!

@tadzik
Copy link

tadzik commented Sep 13, 2024

Github checks look stuck, but it's all good for me locally.

@tadzik tadzik merged commit 1dd2a84 into matrix-org:master Sep 13, 2024
@jkhsjdhjs
Copy link
Author

@tadzik Nice, thanks! Can you also have a look at #117 while you're at it? Couldn't request a review from you there, thanks in advance!

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.

reconnection fails - "Connection got a "close" event"
2 participants