fix: prevent double prekey upload when concurrent uploads race on count=0
uploadPreKeys() waited for a concurrent upload but then proceeded to upload again. With top-up logic and count=0, both handleEncryptNotification and uploadPreKeysToServerIfRequired fire simultaneously, both see count=0, first wins and uploads 800, second waits then uploads another 800 → 1600 prekeys. Fix: return immediately after awaiting the concurrent upload — it already replenished the pool. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -701,10 +701,12 @@ export const makeSocket = (config: SocketConfig) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent multiple concurrent uploads
|
// Prevent multiple concurrent uploads — if one is already running, wait for it and return:
|
||||||
|
// the concurrent upload already replenished the pool, so there is nothing left to do.
|
||||||
if (uploadPreKeysPromise) {
|
if (uploadPreKeysPromise) {
|
||||||
logger.debug('Pre-key upload already in progress, waiting for completion')
|
logger.debug('Pre-key upload already in progress, waiting for completion')
|
||||||
await uploadPreKeysPromise
|
await uploadPreKeysPromise
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadLogic = async () => {
|
const uploadLogic = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user