I Forgot to Add a return Statement and Took Down the API for 3 Hours
I was writing a middleware function in an Express.js app that was supposed to check for a valid token before letting requests through. Everything looked fine — until every protected route started returning 200 OK even without a token. Why? 😑 Because I forgot to put a return before the res.status(401)... line. So next() was being called regardless. 💡 Lesson Learned: Always double-check control flow in middleware. Never trust yourself without tests. Add linting rules to catch missing returns when res is already sent.


