Skip to content

kit: fold webhook dedup into webhookEvents and drop webhookIdempotencyKeys (staged migration) #241

Description

@hyochan

Tracking the DEFERRED(schema-cleanup) note in packages/kit/convex/webhooks/internal.ts (~line 137).

The webhookIdempotencyKeys table duplicates the dedup guarantee that the webhookEvents.by_project_and_notification_id index already provides, roughly doubling per-webhook write amplification. Removing it needs a staged migration across 2-3 coordinated Convex deploys: (1) decide whether the events index key needs source added first - the current dedup key is (projectId, source, sourceNotificationId) while the index alone lacks source, so an Apple/Google notification-id collision within one project could mis-dedup; (2) switch dedup reads to a direct webhookEvents lookup and stop writing webhookIdempotencyKeys; (3) let the table drain past WEBHOOK_RETENTION_MS - legacy rows (pre-projectId, missing eventId) must age out, and the fallback paths at internal.ts:162-223 still handle them today; (4) drop the table from schema.ts plus the hourly prune cron (crons.ts) and the project/account-deletion cascades.

Context: identified during the 2026-07-21 repo-wide health patrol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions