#Backend

8 items tagged “Backend

TILPayments4 min read

Making Stripe Webhook Handlers Idempotent After a Duplicate Purchase Grant

TIL that Stripe can and will deliver the same webhook event more than once, and a handler that reacts to checkout.session.completed by granting access will happily grant it twice — the fix was recording processed event IDs and treating the handler as a set operation, not an append.

#Stripe
TILBackend4 min read

Live Poll Results Without WebSockets: Server-Sent Events in a Node.js API

TIL that once vote writes were race-free, the results screen still felt dead until a manual refresh — switching from client polling to Server-Sent Events made results update instantly without the bidirectional complexity WebSockets would have added for a channel that only ever sends in one direction.

#Node.js
TILBackend4 min read

Preventing Duplicate Votes in a Polling API Under Concurrent Requests

TIL that a 'check if the user already voted, then write' guard is racy under concurrent requests — the fix was a unique compound index plus an atomic $inc, so MongoDB rejects the duplicate instead of the app trying to catch it first.

#MongoDB
TILBackend3 min read

Debugging Problems That Only Appear in Production

TIL that a bug I couldn't reproduce locally turned out to depend on a real difference between environments — request concurrency — that my local setup structurally couldn't produce, no matter how hard I tried to repro it.

#Debugging
TILDevOps2 min read

Choosing Node.js Hosting for a SaaS: What Actually Mattered vs. What I Thought Would

TIL that I picked Render for a Node.js API expecting the deciding factor to be price, and the thing that actually mattered day to day turned out to be deploy simplicity and predictable cold-start behavior.

#Node.js
TILMobile3 min read

Debugging Production API Failures by Reading the Client's Error, Not the Server's Logs

TIL that when a mobile app reports 'network error' against a production API, the fastest path to the actual cause is the client-side error object, not tailing server logs that show nothing wrong.

#React Native
TILBackend3 min read

Debugging a MongoDB/WiredTiger Cache Pressure Issue in Production

TIL that intermittent MongoDB slowdowns that don't show up in query logs can be a WiredTiger cache eviction problem, not a query problem — and the fix was a resource limit, not an index.

#MongoDB
TILBackend3 min read

Designing MongoDB Schemas with Mongoose Without Fighting Yourself Later

TIL that a MongoDB collection modeled around how a screen displayed data instead of how the data actually related caused a rewrite once a second screen needed the same data differently.

#MongoDB