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(ChannelUpdateAction): emit client event in handle to not miss change #10690

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Apokalypt
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
This PR corrects the bug reported in #10658 by moving the emission of events inside the action so that no changes are zapped.
Currently, the <ChannelUpdateAction>.handle method is called within the ThreadChannel and GuildChannelManager classes. This call could result in a modification to the cached instance before the event was received from Discord, causing the event to be lost with the actual modification.

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

@Apokalypt Apokalypt requested a review from a team as a code owner January 4, 2025 23:34
Copy link

vercel bot commented Jan 4, 2025

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jan 4, 2025 11:34pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jan 4, 2025 11:34pm

@SpaceEEC
Copy link
Member

Wouldn't this change cause the update events to be emitted twice when first calling the action from within edit and then from the WebSocket handler?

@Apokalypt
Copy link
Contributor Author

Wouldn't this change cause the update events to be emitted twice when first calling the action from within edit and then from the WebSocket handler?

It will, exactly like the method <Guild>.edit()

In my opinion, it's better to receive two events (one with old/new channels with the same data) than to lose the real modification. On the other hand, I agree with you that it's not ideal and that we should perhaps think about a better solution in general, as other events are subject to the same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants