fix(token): Implement locking for token refresh - #1277
Conversation
1c543a7 to
f8cc3cf
Compare
julien-nc
left a comment
There was a problem hiding this comment.
Thank you very much. Code looks good. A few questions then I'll make some tests and we're good to go.
f8cc3cf to
c6da408
Compare
|
You're right. The token refresh involves network requests to the OAuth2 provider, which typically takes 200-500ms or more. The 100ms wait was pointless because Process A will still be in the middle of the HTTP call... I've pushed a retry mechanism to accomplish this : Process A:
Process B:
This (should) prevent both the race condition and unnecessary duplicate token refreshes. |
c6da408 to
5955dea
Compare
|
I've just found out that this is a bit of a duplicate of #1178 but with another approach... sorry! 🙈 |
|
Please don't be sorry. I'm really not sure writing a lock in the Php session is a viable solution because I don't exactly know when Symfony reads and writes the session data. So we might get outdated data when reading the lock. Using the lock mechanism like you did + the session ID as identifier seems like a better approach. |
5955dea to
cc6570d
Compare
cc6570d to
fe548e1
Compare
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Fix #1175
Added locking mechanism to prevent race conditions during token refresh.
Enhanced error handling and logging for token refresh process.
The fix uses
ILockingProviderto ensure atomic token refresh: