Skip to content

fix: prevent duplicate attachment sends - #1977

Open
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-prevent-duplicate-attachment-send
Open

fix: prevent duplicate attachment sends#1977
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-prevent-duplicate-attachment-send

Conversation

@Ap4sh

@Ap4sh Ap4sh commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Contributor checklist:

Description

Fixes #336

This picks up the approach proposed in oxen-io/session-desktop#3100, which was never merged, and adds focused regression coverage

Repeated Enter presses or send button clicks are now ignored while the current send is still processing attachments

The guard always releases after success or failure, so retrying still works

Tests:

  • added coverage for concurrent sends and guard release after success or failure
  • pnpm ready

Comment on lines +1 to +16
export function createMessageSendGuard() {
let isSending = false;

return async (sendMessage: () => Promise<void>) => {
if (isSending) {
return;
}

isSending = true;
try {
await sendMessage();
} finally {
isSending = false;
}
};
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The way this is setup, I think

  • if a message is being sent to conversationA and takes a while,
  • you switch to conversationB while the one above is still being sent,
  • and try to send a message in conversationB, it wouldn't work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, the guard is now scoped per conversation so a slow send in one conversation doesn't block a send in another one

i added a regression test for that case and pnpm ready passes locally

@Ap4sh
Ap4sh force-pushed the fix-prevent-duplicate-attachment-send branch from ea309fb to 37bf33d Compare September 2, 2026 11:20
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.

[BUG] images sometimes sent twice

2 participants