Skip to content

Avoid duplicate signer approvals for concurrent legacy DM renders - #675

Closed
leonacostaok wants to merge 1 commit into
coracle-social:masterfrom
leonacostaok:fix/dedupe-dm-decrypt
Closed

leonacostaok wants to merge 1 commit into
coracle-social:masterfrom
leonacostaok:fix/dedupe-dm-decrypt

Conversation

@leonacostaok

Copy link
Copy Markdown
Contributor

Opening a legacy DM can request the same signer decryption more than once while the first approval is still pending. ensureMessagePlaintext uses Welshman's Plaintext.ensure, which caches only completed results. Three concurrent calls against the installed 0.10.10 cache invoke the underlying decrypt three times before any resolves.

Share the pending promise per signer, peer and ciphertext at the message boundary. Different accounts, peers and messages remain independent. Remove the promise on either success or rejection so retries work and this helper retains no completed plaintext. The existing persistent cache and signer policy remain unchanged.

Validation: all 12 unit tests pass, including three concurrent callers against the actual cache (including the nested cache used by the signer policy), scope isolation, rejection/retry and cleanup. ESLint passes for changed source files. Full Svelte typechecking is blocked by missing generated declarations for nostr-signer-capacitor-plugin in an install with lifecycle scripts disabled.

This reproduces a legacy-DM duplicate-approval race. It does not establish that every repeated prompt has this cause; separate NIP-17 unwrap stages are outside this fix.

@staab

staab commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Fixed in https://gitea.coracle.social/coracle/welshman/pulls/68, this will be in the next release. Thanks for the report!

@staab staab closed this Sep 30, 2026
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.

2 participants