So imagine I’m reading your post. I click Like , the heart turns red, and the request times out. My frontend’s retry logic sends it again.
This time, the success reply arrives. The heart turns grey.
I know I liked your post. But your code apparently has other plans because its not FAULT TOLERANT.
Fault tolerance is an application’s ability to keep working correctly when part of the system fails. Retrying can help us recover from a temporary connection failure, but our API has to handle the second attempt safely.
For database writes, there’s a catch. Saving the change and delivering the HTTP response are separate steps. The connection can drop after the database commits, leaving the client unsure whether the write succeeded.
Let’s follow that click through MongoDB and PostgreSQL on Neon , then make the retry safe in both.
One click became two requests
Our endpoint is POST /posts/42/toggle-like . It reverses the current state. If my like exists, remove it.…