You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current token refreshing mechanism in core-http was wrong. The token was being refreshed before the "refresh time buffer" was reached. I've added tests to verify the behavior (if we change the source back, the tests do fail, as expected).
With this PR, here's what we will be doing:
1. If a token is not there or has expired, we ask for a new one (of course).
2. Before a token expires, in a time window, we try to retrieve the token through a refresh promise.
3. As we get new requests to retrieve that token, we re-use the same refresh promise.
4. If the refresh promise fails, next incoming request will re-run the refresh promise only after some specific time. (This is true again, I reverted my changes to this)
Please let me know how this looks! Feedback appreciated.
Reverted: ~**[Important]**
The update after Jeff's approval is to fix the behavior to match the original intention. Only within the refresh window, while the valid token is still returned, the refresh promise should try to refresh the token once every 30 milliseconds (configurable) until the token expires. Once the token expires, the process does a final attempt to update it, then it stops.~
Incidentally fixes this customer issue, in which the token was refreshed more times than expected:
FixesAzure#13369
Copy file name to clipboardExpand all lines: sdk/core/core-http/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
## 1.2.4 (Unreleased)
4
4
5
+
- Updated the `bearerTokenAuthenticationPolicy` to refresh tokens only when they're about to expire and not multiple times before. This fixes the issue: [13369](https://github.com/Azure/azure-sdk-for-js/issues/13369).
0 commit comments