If your app shows the status of something that happens somewhere else (a payment, a shipment, a crypto swap), you usually get updates two ways: the provider sends webhooks, and you poll its API as a backup. Both paths feed the same screen.
That's where a quiet bug lives. Webhooks are delivered at least once, so the same event can show up twice. They can arrive out of order after a retry. And a poll that started a second before a webhook can finish a second after it, carrying older data. If every update simply overwrites the stored status, your user sees "sending", then "confirming" again, then "sending". On a screen that shows their money, that looks like something went wrong.
The fix is small: run every update, from either path, through one function that decides whether it's allowed to change anything.
Don't rank the statuses
The first idea most people have is to give each status a number and only move forward.…