Reaction count shows 2 instead of 1 for own message (optimistic-update vs WS-broadcast race) #31
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_collab#31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Reacting to one's own message renders count
2instead of1. Clicking again removes both. Server-side state is correct (one reaction row in the DB) — only the client UI miscounts.Root cause (race)
chat-app.js::toggleReactiondoes an optimistic local update afterawait rpc('message.toggle_react')returns:The server persists the reaction and broadcasts a
message.reactedevent to all channel members including the sender (multi-tab parity per the WS-refactor design). When the WS event lands faster than the HTTP RPC response — common under any non-trivial server load — the timeline becomes:onMessageReactedarrives → replacesmsg.reactionswholesale with the server list (already contains caller's row).awaitresolves → optimisticpushappends a second copy of the same(emoji, user_id)row.2.Surfaced in
#10 dogfooding thread — reacting to own message in chat.
Fix in
PR linked below.