Skip to content

Maybe fix votes?#172

Merged
c0unts merged 2 commits into
mainfrom
fix-votes-maybe
Apr 10, 2026
Merged

Maybe fix votes?#172
c0unts merged 2 commits into
mainfrom
fix-votes-maybe

Conversation

@5731la

@5731la 5731la commented Apr 10, 2026

Copy link
Copy Markdown
Member

No description provided.

@5731la 5731la requested review from c0unts and Copilot April 10, 2026 17:56
@5731la 5731la requested a review from a team as a code owner April 10, 2026 17:56
@c0unts

c0unts commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

giving a quick test in test server

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the /vote rank-choice interaction flow to better handle “late” Discord component interactions by adding a done signal and cleaning up the registered component handler when voteGetVote returns.

Changes:

  • Add a done channel to let the component handler stop forwarding interactions after voteGetVote completes.
  • Delete the per-message component handler on function exit to avoid leaking entries in ComponentHandlers.
  • Add deferred cleanup for channels and handler state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread commands/slash/vote.go
Comment on lines +392 to +397
defer func() {
close(done)
delete(*ComponentHandlers, messageSlug)
close(selectionChan)
close(interactionCreateChan)
}()

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

Closing selectionChan / interactionCreateChan here is unsafe: the component handler can still be invoked after voteGetVote returns (e.g., an interaction already dispatched but not yet executed). In that case the handler’s select { case selectionChan <- ...; case <-done: } may randomly choose the send case after the channel is closed, which will panic (send on closed channel). Prefer not closing these channels at all (they’ll be GC’d), or ensure the handler cannot run concurrently with the closes (e.g., guard with a mutex/once and never select on a send to a potentially-closed channel).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"they'll be GC'd" what a statement

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@c0unts c0unts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we will try

@c0unts c0unts merged commit 38fd2dc into main Apr 10, 2026
9 checks passed
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