Skip to content
Back to snapcart-api report
ReliabilityHigh

Unhandled Promise Rejection

src/api/webhooks/order.ts:87

What's going on

The order webhook handler fires an async processing task without attaching a rejection handler, so failures drop silently into the void.

Why it matters

Silent failures in payment-adjacent flows are the worst kind: the customer sees success, the system records a failure state, and money or inventory drifts out of sync.

src/api/webhooks/order.ts:87

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
1router.post("/order", async (req, res) => {2  const event = validateSignature(req);3  res.status(202).json({ accepted: true });4  processOrder(event).catch(() => void 0); // swallowed5});
After
1router.post("/order", async (req, res) => {2  const event = validateSignature(req);3  res.status(202).json({ accepted: true });4  try {5    await processOrder(event);6  } catch (err) {7    reportService.recordFailure("order", event.id, err);8  }9});
  1. Uploaddone
  2. Analyzedone
  3. Finddone
  4. Explainactive
  5. Fixupcoming
  6. Testupcoming
  7. Verifyupcoming