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:
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
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- Verify the signature, store or enqueue the event, and respond right away.
- 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
- Unauthenticated routes that use your users' stored API keys: If users save their own model API keys in your app, a route that uses them without checking who's calling lets strangers spend your users' money.
- Background jobs that run inside requests: Work fired off from a request handler without a queue dies on deploys and crashes, never retries, and competes with live requests for the same server.
- Database connection pools on serverless: On serverless hosting every concurrent function instance opens its own pool, so the total quickly exceeds what the database allows.
- A new database connection per request: Opening a fresh database connection on every request spends time and database capacity on setup, and runs into the connection limit long before the database is busy.
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.