A misplaced React object literal caused a self-inflicted DDoS and crashed a production database

A routine Tuesday deployment introduced a subtle React bug that triggered an uncontrolled API request loop, bombarding an internal endpoint thousands of times per second per user. The root cause was a plain JavaScript object declared inside a functional component's body and used as a useEffect dependency. Because React compares object dependencies by memory reference rather than value, each re-render created a new object that appeared changed, retriggering the effect and updating state in an infinite cycle. Database CPU utilization spiked to 99.8% and API response times exceeded 8,000 milliseconds before the team rolled back the deployment. The issue was resolved by replacing the object dependency with primitive values, which JavaScript compares by value and therefore remain stable across re-renders.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in