Skip to content

fix: remove duplicate ACK in handle_message to prevent message re-delivery#86

Open
octo-patch wants to merge 1 commit into
shaxiu:mainfrom
octo-patch:fix/issue-66-remove-duplicate-ack
Open

fix: remove duplicate ACK in handle_message to prevent message re-delivery#86
octo-patch wants to merge 1 commit into
shaxiu:mainfrom
octo-patch:fix/issue-66-remove-duplicate-ack

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #66

Problem

The main() loop already sends an ACK response for every incoming WebSocket message that contains a mid header (lines 654–667). However, handle_message() was sending a second, identical ACK at the start of every call before doing any processing.

This means the server received two ACKs per message. Many WebSocket-based messaging protocols interpret a duplicate ACK as a sign that the original delivery failed, and respond by re-sending the same message with a new delivery timestamp. This can cause:

  • The bot to process the same buyer message multiple times
  • Multiple AI-generated replies sent to a single buyer message
  • Unexpected memory growth from message storms under high traffic

Solution

Remove the redundant ACK block (19 lines) from handle_message(). The main() loop already handles ACKs for all messages — including the app-key, ua, and dt header fields — so no functionality is lost.

Testing

  • Verified that main() sends the ACK before calling handle_message(), covering all cases.
  • Heartbeat responses are handled separately via handle_heartbeat_response() and do not go through handle_message(), so they are unaffected.
  • The change is a pure deletion with no new logic introduced.

…ivery

The main() loop already sends an ACK for every incoming WebSocket message
that contains a 'mid' header. handle_message() was sending a second
identical ACK, causing the server to potentially interpret the duplicate
as a delivery failure and re-send the same message with a new timestamp.

This redundant ACK is the likely root cause of the duplicate message
processing issue (related to shaxiu#66) where the bot generates and sends
multiple replies for a single buyer message.

Fixes shaxiu#66
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.

貌似有内存溢出问题。

1 participant