mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
Fix duplicate WhatsApp outbound delivery.
Claim pending rows atomically and serialize the sidecar poller so overlapping polls cannot send the same reply twice; also stop inbound queue delivery from falling through to a second enqueue. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
10ae4abc1d
commit
b6e023cd91
6 changed files with 193 additions and 14 deletions
|
|
@ -973,10 +973,17 @@ async function pollOutboundQueue(sock: ReturnType<typeof makeWASocket>): Promise
|
|||
|
||||
function startOutboundPoller(getSock: () => ReturnType<typeof makeWASocket> | null): void {
|
||||
const intervalMs = Number(process.env.OCLAW_WHATSAPP_OUTBOUND_POLL_MS || "1000") || 1000;
|
||||
// Overlapping polls used to claim the same pending row twice (send → duplicate WhatsApp
|
||||
// bubbles) once inbound replies also went through the outbound queue.
|
||||
let pollInFlight = false;
|
||||
setInterval(() => {
|
||||
if (pollInFlight) return;
|
||||
const s = getSock();
|
||||
if (!s) return;
|
||||
void pollOutboundQueue(s);
|
||||
pollInFlight = true;
|
||||
void pollOutboundQueue(s).finally(() => {
|
||||
pollInFlight = false;
|
||||
});
|
||||
}, Math.max(1000, intervalMs));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue