JI
Skip to content
All posts
MERNMarch 21, 2026·10 min read

Shipping a MERN app that doesn't fall over

Mongo indexes, Express error boundaries, and the boring reliability work that keeps a Node.js API returning fast under real traffic.

A MERN demo works on the first request. A MERN product works on the millionth, on a slow network, when Mongo is under load. The gap between the two is unglamorous reliability work.

Index for your queries, not your data

The most common production slowdown I see is a collection scan hiding behind a find(). Add compound indexes that match your actual query and sort order, then confirm with explain().

postSchema.index({ authorId: 1, createdAt: -1 });
// matches: Post.find({ authorId }).sort({ createdAt: -1 })

One error boundary, one response shape

Wrap async handlers so a thrown error always becomes the same JSON envelope. The React client then handles one failure shape instead of ten.

  • Centralize error handling in one Express middleware.
  • Return { error: { code, message } } — always the same keys.
  • Log the stack server-side; send the client a code it can branch on.

None of this shows up in a screenshot. All of it shows up in the on-call channel when you skip it.