I let AI refactor our async error handling and spent two weeks debugging what it fixed
Six months ago our Express app had a straightforward error handling pattern. Not pretty, but it worked. Every route wrapped in try/catch, errors forwarded to a central middleware. Simple.
Then I let an AI tool refactor it. The model said our approach was inconsistent and proposed a cleaner async wrapper pattern. It looked good. I reviewed it quickly, merged it.
Two weeks later we had the strangest production bugs. Requests hanging indefinitely. No errors in logs. Users reporting timeouts on specific endpoints. Our monitoring showed no exceptions thrown anywhere.
Turns out the refactor had introduced silent promise rejections in three middleware functions. The wrapper caught synchronous errors fine but swallowed async ones silently. Node 18 behavior around unhandled rejections was masking it differently than our local Node 16 environment.
We spent two weeks adding logs everywhere, reverting suspected changes, blaming a library update. The AI refactor never crossed our minds as the culprit because the code looked cleaner than what we had before.
I eventually found it by bisecting git history at 2am after everyone else gave up.
The irony is the original ugly code would have thrown a visible error immediately. The AI made it prettier and silently broken.
Anyone else been burned by a refactor that looked correct but changed error propagation behavior in subtle ways?
Posted Apr 5, 2026, 3:15 PM UTC