Finding · affects your reliability

Webhooks processed synchronously

A webhook handler that does its work before responding makes the sender retry under load, which doubles the traffic on an already slow handler.

Why it matters

Stripe, GitHub and most webhook senders wait only a few seconds and retry when a response is slow or fails. If your handler writes to the database, calls other APIs or runs a model before answering, a busy moment makes it slow, and the retries arrive on top of the original traffic.

The result is duplicated work at the worst possible time, and if the handler isn't idempotent, duplicated side effects: two emails, two credits, two records.

What it looks like

All the work happens before the 200:

Before
export async function POST(req: Request) {
  const event = verify(await req.text(), req.headers);
  await fulfillOrder(event);    // database writes, emails, API calls
  return new Response("ok");
}

How to fix it

After
export async function POST(req: Request) {
  const event = verify(await req.text(), req.headers);
  await queue.send(event);      // store it, answer immediately
  return new Response("ok");
}
// worker: fulfillOrder(event), keyed on event.id so retries are no-ops
  1. Verify the signature, store or enqueue the event, and respond right away.
  2. Process events in a worker, keyed on the event id so retries are harmless.

A real example: Formbricks

Computed by Skeram’s engine from the published teardown of Formbricks, at 100,000 monthly users (critical):

1 webhook processes synchronously. /api/billing/stripe-webhook. Webhook senders (Stripe, GitHub) retry on slow responses — under load, retries pile onto the same overloaded handler, doubling write traffic exactly when you can least afford it.

Suggested fix: Ack immediately, enqueue the payload, process in the worker with idempotency keys.

Evidence: app/api/billing/stripe-webhook/route.ts.

How Skeram detects it

Skeram identifies inbound webhook routes and what they do. A webhook that writes data or does more than light work before responding is flagged.

When it starts to hurt: A warning from about 10,000 monthly users, critical around 100,000, when bursts make handlers slow enough to trigger retries.

Every finding cites the file and line it came from, and scanning again after a fix shows it resolved in History. How the analysis works.

Questions

My handler is idempotent. Do I still need this?

Idempotency makes retries safe; it doesn't make them free. Answering fast prevents most retries in the first place.

Related findings

Find it in your code

Skeram reads your repo, prices every model call from 100 to 100,000 users, and flags these patterns with the file and line.