Skip to content
Back to snapcart-api report
ReliabilityMedium

Webhook Delivery Has No Retry

src/services/events.ts:57

What's going on

A webhook whose first delivery fails is dropped, so downstream services can miss inventory and fulfillment events permanently.

Why it matters

Event-driven systems without retry policy silently lose messages, producing state drift that is very hard to debug later.

src/services/events.ts:57

Recommended Fix

Replace the inline query with a parameterized statement and validate the id before it ever reaches the database. A regression test is generated alongside the patch.

Before
1export async function publishWebhook(url: string, payload: unknown) {2  await fetch(url, { method: "POST", body: JSON.stringify(payload) });3}
After
1export async function publishWebhook(url: string, payload: unknown) {2  for (let attempt = 1; attempt <= 3; attempt++) {3    const res = await fetch(url, {4      method: "POST",5      body: JSON.stringify(payload),6    });7    if (res.ok) return;8    await sleep(attempt * 1_000); // exponential-ish backoff9  }10  await enqueueDeadLetter(url, payload);11}
  1. Uploaddone
  2. Analyzedone
  3. Finddone
  4. Explainactive
  5. Fixupcoming
  6. Testupcoming
  7. Verifyupcoming