Free practice · about 5 minutes · no signup
One webhook. Two deliveries. One bug to catch.
A teammate asks you to review a small change. Read the ticket, inspect the handler, and make three decisions. You’ll get an explanation after each one.
PRACTICE TICKET / 001
Stop duplicate account credits
A verified webhook grants credits to an account in our database. The provider may deliver the same event more than once, and two workers may handle it concurrently.
Acceptance criterion: each distinct event applies its credit increment once, even if a worker fails and the provider retries.
async function handleWebhook(event) {
const seen = await db.events.find(event.id);
if (seen) return { status: 200 };
await db.credits.increment(event.accountId, event.credits);
await db.events.insert({ id: event.id });
return { status: 200 };
}Assumptions: the signature and payload have already been validated; event IDs are stable within this provider/account; both writes use the same transactional database. External API side effects need a different recovery design.
New to idempotency? Read the walkthrough first →Decision 1 of 3
Find the failure window
Guided practice with written explanations. No code is executed. Answers stay in this page and reset when you reload.