When 5 requests hit 401 at the same time — the small IT horror begins
In PDP Mobile and WikiMind we hit a race condition: the JWT expired, 5 parallel requests all tried to refresh the token at once. We fixed it with an Async Mutex so refresh runs one at a time, without duplicates.

In PDP Mobile and WikiMind, we hit a classic race condition: the JWT expired, 5 parallel requests came in, and each one decided it was the one that should refresh the token. The result: extra load, duplicate refresh requests, and behavior at the level of “first come, first served.”
We fixed it with an Async Mutex: the first request takes the “key” and performs the refresh, while the others wait for the result. As soon as the token is updated, all of them continue working with the new JWT, without chaos or duplicates.
We rolled out this pattern both in the mobile app and in the web platform. In an era where everyone has 100 async operations per second, things like this are no longer a “nice to have” — they’re production basics.
In short, a mutex is like that colleague who says: “Okay, let’s refresh the token one at a time, no rush” 😄