Shruti’s developer tools · Complete free demo

Free worked exercise · Original synthetic data

Test duplicate webhook effects locally before connecting a provider

A repeated delivery can apply the same effect twice. This example makes that failure visible with a counter, then rehearses a retry after failure.

Run the synthetic proof

Not run yet. Supplied synthetic fixtures only.

No account or payment needed. This exercise sends no input-upload requests and stores no inputs. Normal host access logs may exist.

Run one event twice

The naive example applies two effects. The guarded example applies one and reports the second identical attempt as a duplicate. Inspect the effect count rather than inferring correctness from a response code.

Fail before the effect, then retry

The sample raises a synthetic error before changing the counter. At that point there are zero effects and zero completed entries. Retrying applies one effect. Recording completion before a failed write could prevent the intended work from ever happening.

Expected results

naiveEffects: 2
guardedEffects: 1
safeResults: ["applied", "duplicate"]
beforeRetry: {"effects": 0, "completed": 0}
afterRetry: {"effects": 1, "completed": 1}

Review identity conflicts

The same ID with a changed resource or value is flagged as a collision. Your provider and business model define the real identity rules.

Where this exercise stops

It is synchronous and in memory. No HTTP response, remote effect, ordering, concurrency, signatures or restart recovery is tested. Production handlers need authentication and an appropriate atomic durable boundary. Passing this exercise cannot establish those guarantees.

Stripe’s documentation covers duplicate delivery, retries and event ordering and provides local testing tools. Use the provider’s actual contract.

Download and reproduce

Download the free exercise ZIP

Extract the ZIP and run with Node.js 22+:

node run.mjs
node exercise.test.mjs

No npm install or API key. Read the README and license before adapting.

What the separate paid download adds

The separate USD 12 HookReplay kit adds a reusable local adapter/test template and broader synthetic scenarios.

Provider documentation and your own tests may be sufficient. The paid download supplies reusable learning/testing material, not production webhook infrastructure.

Inspect the USD 12 download on Payhip · Delivery and usage details