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(WebSocketShard): either start close timeout or emit destroyed but never both #8956

Merged
merged 3 commits into from Dec 25, 2022

Conversation

Qjuh
Copy link
Contributor

@Qjuh Qjuh commented Dec 20, 2022

Please describe the changes this PR makes and why it should be merged:
#7626 introduced a WebSocketShard#wsCloseTimeout() to listen for zombie connections and reconnect when zombie connections get detected.

This fix was going a bit too far, as the timeout was also starting if WebSocketShard#destroy() was emitting the WebSocketShard#destroyed event. In those cases we don't need to listen for zombie connections anymore, as the WebSocketManagerwill reconnect the shard anyway.

But this lead to the Websocket connection being unneccessarily destroyed after the reconnect, because the timeout happened after the new connection already got made.

This PR now only starts the wsCloseTimeout if the WebSocketShard#destroy() method doesn't emit the WebSocketShard#destroyed event.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@vercel
Copy link

vercel bot commented Dec 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated
discord-js ⬜️ Ignored (Inspect) Dec 25, 2022 at 7:54AM (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Dec 25, 2022 at 7:54AM (UTC)

@legendhimself
Copy link
Contributor

These changes makes sense and looks good to me. Have you tested these changes?

Qjuh and others added 2 commits December 20, 2022 20:51
Co-authored-by: Voxelli <69213593+legendhimself@users.noreply.github.com>
Copy link
Contributor

@legendhimself legendhimself left a comment

Choose a reason for hiding this comment

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

LGTM, Gonna test it on a few bots.

@kodiakhq kodiakhq bot merged commit 43ce2a5 into discordjs:main Dec 25, 2022
@Qjuh Qjuh deleted the fix-ws-destroy-loop branch December 26, 2022 12:03
legendhimself added a commit to legendhimself/discord.js that referenced this pull request Dec 28, 2022
- Fix backport discordjs#7626 missing changes
- Reverted the pull request discordjs#8956
- Removed unref of wsCloseTimeout
- We are resuming the connection for zombie instead of starting a new

Co-authored-by: DraftMan <nicovanaarsen@gmail.com>
legendhimself added a commit to legendhimself/discord.js that referenced this pull request Dec 31, 2022
- Fix backport discordjs#7626 missing changes
- Reverted the pull request discordjs#8956
- Removed unref of wsCloseTimeout
- We are resuming the connection for zombie instead of starting a new

Co-authored-by: DraftMan <nicovanaarsen@gmail.com>
kodiakhq bot pushed a commit that referenced this pull request Jan 1, 2023
* fix: zombie connection
- Fix backport #7626 missing changes
- Reverted the pull request #8956
- Removed unref of wsCloseTimeout
- We are resuming the connection for zombie instead of starting a new

Co-authored-by: DraftMan <nicovanaarsen@gmail.com>

* refactor: ♻️ Format code and remove useless assignation

Co-authored-by: DraftMan <nicovanaarsen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants