Right now in CoreWSProvider we store the promises and reuse them to prevent duplicated WS calls. This has been a great improvement in the app.
However, I noticed a case where this doesn't work. In a place where the same WS call is made twice with a bit of delay we have this race condition:
- First call starts, checks if it's in cache.
- First call is not in cache, starts the WS call.
- Second call starts, check if it's in cache.
- First call ends and starts storing in DB.
- Second call is not in cache (yet), starts the WS call (again!).
We could store the promises in CoreSite like we do in CoreWSProvider. In this case, we should only reuse the promise if the preSets are the same.