fix: add idempotency to prevent duplicate messages on network redelivery (#10)#19
Open
fix: add idempotency to prevent duplicate messages on network redelivery (#10)#19
Conversation
…ery (#10) - Add HashSet to track received message IDs in AppState - Check for duplicate message IDs before processing in handle_incoming_message - Silently ignore duplicate messages (log in debug builds) - Clear message ID tracking when session closes to allow reusing IDs in new sessions - Prevents duplicate messages from I2P network redelivery from appearing in chat This fixes issue #10 where I2P network redelivery could cause the same message to appear multiple times in the chat. Now messages are tracked by ID and duplicates are automatically filtered out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Add idempotency to prevent duplicate messages on network redelivery
Closes #10
Problem
When I2P network conditions cause redelivery of the same message (a documented behavior of I2P's unreliable delivery semantics), the same message appears multiple times in the chat interface. This creates:
This is particularly problematic on unstable I2P connections during router bootstrapping or when tunnels degrade.
Solution
Implement message ID tracking for idempotency:
HashSet tracking:
received_message_ids: Mutex<HashSet<String>>toAppStateDuplicate detection in
handle_incoming_message:Cleanup on session close:
close_sessionis called, clear thereceived_message_idssetSecurity considerations
Implementation details
std::collections::HashSetfor efficient duplicate detection