- Home
- Skills
- APIs & Backend
- Repair Webhook Replay & Delivery Bugs
More screenshots
Works with the AI Agents you already use
Repair Webhook Replay & Delivery Bugs
Diagnose and repair webhook delivery, replay protection, retries, ordering, acknowledgement, and reconciliation.
$1
Repair Webhook Replay & Delivery Bugs
Example session with this skill installed
Our Stripe webhook handler is creating duplicate orders when Stripe retries a delivery. Here is the current Node/Express handler code. Can you fix the idempotency issue?
- Read your context and instructions
- Compiled the repair webhook replay
I have analyzed the handler. The issue stems from the database insert occurring before the idempotency check is committed, creating a race condition during rapid retries.
Webhook Idempotency Repair
const express = require('express');
const router = express.Router();
const db = require('./db'); // Hypothetical DB client
router.post('/webhook', async (req, res) => {
const sig = req.headers['stripe-signature'];
const event = req.body;
// 1. Verify event identity
const eventId = event.id;
try {
// 2. Use a transaction to ensure atomicity
await db.transaction(async (tx) => {
// 3. Check for existing processed event (The Invariant)
const existing = await tx.query(
'SELECT id FROM processed_events WHERE id = $1 FOR UPDATE',
[eventId]
);
if (existing.length > 0) {
console.log(`Event ${eventId} already processed. Skipping.`);
return;
}
// 4. Business logic: Create order
await tx.query(
'INSERT INTO orders (user_id, amount, status) VALUES ($1, $2, $3)',
[event.data.object.metadata.user_id, event.data.object.amount, 'paid']
);
// 5. Record event processing
await tx.query(
'INSERT INTO processed_events (id, processed_at) VALUES ($1, NOW())',
[eventId]
);
});
// 6. Acknowledge early only after durability is guaranteed
res.json({ received: true });
} catch (err) {
console.error(`Webhook Error: ${err.message}`);
// Return 4xx/5xx to trigger provider retry
res.status(500).send('Webhook handler failed');
}
});
Deterministic Test Plan
Duplicate Delivery Test: Mock two concurrent requests with the same evt_123 ID. Verify the DB contains exactly one order and one processed_events record.
2.
Partial Failure Test: Force an error during the order insertion. Verify that the processed_events record is NOT created, allowing for a future retry.
Next steps
- Create the
processed_eventstable with a primary key onid. - Verify your DB driver supports
FOR UPDATEor equivalent row-level locking. - Update the Stripe webhook secret in your environment variables.
Connects securely to your tools. The creator never sees your data.
About this skill
Repair Webhook Replay & Delivery Bugs targets production and repository defects around diagnose and repair webhook delivery, replay protection, retries, ordering, acknowledgement, and reconciliation.. It examines signature and timestamp verification, event identity and deduplication, provider retry semantics, acknowledgement timing, out-of-order delivery handling, dead-letter and poison-event paths, consumer idempotency and side effects, reconciliation and delivery observability, then establishes one explicit repair contract and focused deterministic validation.
The skill works from repository access or partial evidence such as snippets, logs, configuration, traces, and architecture notes. It preserves existing product/security policy, avoids invented execution claims, and keeps production systems, real credentials, and deployment outside the validation path.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Requires specific logs, provider contracts, or code snippets to provide accurate repairs. Does not integrate directly with live production monitoring tools.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago