Skip to content

fix: land the stranded inbound-webhook + broadcast reliability work on main - #449

Open
ArnasDon wants to merge 1 commit into
mainfrom
fix/webhook-broadcast-reliability-replay
Open

fix: land the stranded inbound-webhook + broadcast reliability work on main#449
ArnasDon wants to merge 1 commit into
mainfrom
fix/webhook-broadcast-reliability-replay

Conversation

@ArnasDon

Copy link
Copy Markdown
Owner

Re-lands commit e6e34bd — the work reviewed and approved in #388 — which
never reached main.

What happened

#388 was opened with fix/duplicate-conversations as its base rather than
main. That branch had already merged to main via #364, so when #388 merged
on 2026-07-14 its content went into a branch that was already spent. main
has been missing all of it since:

So on main today, a Meta webhook retry still double-counts unread and
re-fires automations, flows, and AI auto-reply for the same message.

Side effect worth noting: migration number 037 has been sitting free, and
open PR #403 has claimed it for 037_agent_templates_permission.sql. One of
the two will need renumbering.

One conflict, resolved toward main

main has since gained 59dbf27 (#409), which made the automation-trigger
dispatch inside after() sequential. e6e34bd had made the same dispatch
concurrent via Promise.all (#368). Both fix the same underlying hazard —
a detached promise being frozen when the after() callback resolves — so I
kept main's sequential version, which is the newer and more conservative of
the two and avoids concurrent automations racing on the same log row. Nothing
e6e34bd needed is lost.

Verification

eslint 39 warnings / 0 errors (unchanged from main), tsc --noEmit clean,
658 tests pass, next build exits 0.

Not exercised against a live Supabase — the migration is unchanged from the
version already reviewed in #388, but it has never actually been applied to a
database on the main line, so it deserves a look before deploy.

🤖 Generated with Claude Code

…es, and partial failure

Addresses four reliability bugs (#367, #368, #369, #370). Each pairs a
DB-level guarantee (new migration 037) with the corresponding code change,
since the application layer alone can't make these operations atomic.

     downstream side effect. Adds a unique index on
     (conversation_id, message_id) — the correctly-scoped idempotency key —
     and turns the message INSERT into an ON CONFLICT DO NOTHING upsert.
     An empty result means "replay": acknowledged as a no-op before the
     unread bump and all fan-out.

     after(), so a serverless freeze could interrupt them. They are now
     awaited via Promise.all; each keeps its own .catch so one failure
     neither blocks the others nor becomes an unhandled rejection.

     read-modify-write. Replaced with a DB-side atomic increment
     (bump_conversation_on_inbound RPC), mirroring migration 007.

     no recipients. Parent + recipients are now inserted in one
     transaction (create_broadcast_with_recipients RPC); a recipient
     failure rolls the parent back.

Adds regression tests for all four (webhook route + broadcast-core).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@supabase

supabase Bot commented Jul 29, 2026

Copy link
Copy Markdown

Updates to Preview Branch (fix/webhook-broadcast-reliability-replay) ↗︎

Deployments Status Updated
Database ⏸️ Wed, 29 Jul 2026 20:16:13 UTC
Services ⏸️ Wed, 29 Jul 2026 20:16:13 UTC
APIs ⏸️ Wed, 29 Jul 2026 20:16:13 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ⏸️ Wed, 29 Jul 2026 20:16:13 UTC
Migrations ⏸️ Wed, 29 Jul 2026 20:16:13 UTC
Seeding ⏸️ Wed, 29 Jul 2026 20:16:13 UTC
Edge Functions ⏸️ Wed, 29 Jul 2026 20:16:13 UTC

❌ Branch Error • Wed, 29 Jul 2026 20:16:17 UTC

unexpected status 404: {"message":"Postgres config not found"}

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

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.

1 participant