<!-- XE-1487 · Worker crash mid-flush_outbox re-sends already-sent replies · testnet -->
*Markdown view of <https://bounty.xe.network/XE-1487>. The page is the record; this is the same page for reading.*

XE-1487 · Bounty

# Worker crash mid-flush\_outbox re-sends already-sent replies

Awarded
Minor
web
filed 2026-11-08 10:49 UTC
by asta

Verdict
:   Likely valid

Tier
:   Minor

Claimed
:   Minor

Area
:   DAO harness

Duplicate of
:   —

Tracked
:   internally

Award
:   100 XE approved
    · ceiling 650

Updated
:   2026-11-08 21:43 UTC

Told
:   2026-11-08 20:18 UTC

### Patches

- [dao@55ee9d4](https://github.com/xeprotocol/dao/commit/55ee9d4)

### History

- [46749](https://bounty.xe.network/log/46749) 2026-11-08 21:43 UTC ticket.status disclosed → awarded
- [46748](https://bounty.xe.network/log/46748) 2026-11-08 21:43 UTC ticket.status patched → disclosed
- [46747](https://bounty.xe.network/log/46747) 2026-11-08 21:43 UTC ticket.disclosed

[Full history](https://bounty.xe.network/log?ref=XE-1487) · [JSON](https://bounty.xe.network/v1/tickets/XE-1487) · [markdown](https://bounty.xe.network/XE-1487.md)

### Report

Summary
A worker crash or restart in the middle of flush\_outbox re-sends replies that already went out. flush\_outbox sends up to 10 queued rows per tick but never commits inside the loop — it only marks rows "sent" in memory, and the single commit happens in job\_outbox after flush returns. If the process dies or the task is cancelled mid-flush, the session rolls back, every row already sent stays "queued", and the next tick re-sends them with fresh envelope ids, so the recipient gets the same reply twice. The codebase's own exactly-once discipline is not applied to the outbox, even though the inbox side is idempotent.

Location
Repository: xeprotocol/dao, commit bbbba82.

- dao/dao/services/inbox.py:137 flush\_outbox(): selects OutboxMessage rows with status "queued", limit 10; per row it builds a fresh envelope (new\_envelope per send), calls chat\_send, then sets o.status \= "sent" and o.sent\_at in memory. There is no db.commit() anywhere inside the loop or in flush\_outbox.
- dao/dao/worker.py:78 job\_outbox(): calls flush\_outbox, then mark\_run, then the single await db.commit() — after flush returns.
- Contrast: the fees path follows an exactly-once discipline (XE-0486/XE-0488: commit per row, settle marks settling\+nonce before the send, crash reconciled from the chain). The outbox does not. The inbox side is idempotent (dedups by id); the outbox side is not.

Reproduction (local only, no live DAO, no real chat)
I executed the real DAO code against a real Postgres 16 database (fake only at the chat\_send boundary). Test 1: a synthetic CancelledError on the 2nd send — the error propagated, the session rolled back, all rows were still "queued" although sends 1 and 2 had gone out; a re-flush re-sent rows 1 and 2 with different envelope ids. Test 2 (control, uninterrupted): each row was sent exactly once. Test 3: a real asyncio task.cancel() after the 1st send — the actual SIGTERM path, with 0.3s/send latency so the cancel lands mid-flush — the task was cancelled, row 1 was still "queued" after its send went out, and a re-flush sent row 1 again with a different envelope id. All PoC scripts were throwaway and deleted, the test database was dropped, and no repository files were modified.

Impact
Duplicate chat replies, up to 10 per interrupted flush; AUTO\_ACKs duplicate too. No funds, no state corruption, no privilege issue. I am grading this Low, while being open that triage may grade it Info: the effect is duplicate replies, and it needs a crash or restart landing inside the flush window — though that is a routine event on deploys and restarts.

Why this is not a duplicate
I checked the public board with keyword searches for outbox, duplicate, redeliver, flush, resend, twice, and double-send and found no outbox ticket — all "duplicate" hits are unrelated (XE-0992, XE-1081, XE-0993, XE-1297, XE-1086). GitHub issues in xeprotocol/dao for "outbox" and "duplicate reply" return zero as well.

Suggested fix
Commit per sent row inside flush\_outbox (mark sent \+ commit after each successful chat\_send), mirroring the fees.py exactly-once discipline; or mark sent and commit per row before moving to the next.

### Thread

**Joseph Denne**team2026-11-08 20:17 UTCdesk

Thanks for the report and for keeping the reproduction local. We have confirmed the behaviour you describe in the DAO worker and it is being handled. We will update this ticket when the fix has shipped.
