Debugging a Race Condition at 2am
Tarek Ferdous · October 21, 2025 · Toronto, ON
The test only failed on CI, never locally. That should have been the first clue that timing, not logic, was the culprit.
Turned out two promises were racing to write the same cache key. Adding a mutex around the write fixed it in one line, after four hours of staring.