Async work outliving request lifecycle in Node backend

A JavaScript production issue I don’t see discussed enough: async work outliving the request. In a Node backend, I had an endpoint doing async enrichment after responding: app.post("/event", async (req, res) => { res.send("ok"); await sendToAnalytics(req.body); await updateSearchIndex(req.body); }); Looks fine. Works locally. Then production load hits. Requests start piling up. Memory usage creeps up. Shutdowns hang. Why? Because the request lifecycle ended, but the async work didn’t. Nothing was cancelable. Nothing was bounded. Errors had nowhere to go. The fix wasn’t “await less”. We moved async side effects behind a job boundary: push work to a queue enforce retries + timeouts make jobs idempotent allow graceful shutdowns Now the request path is fast and predictable, and background work is observable. JavaScript makes it easy to start async work. Production systems demand you control when it stops. #JavaScript #NodeJS #BackendEngineering #ProductionBugs #DistributedSystems #WebDevelopment #EngineeringLessons

To view or add a comment, sign in

Explore content categories