Commit ce410ea
committed
fix(auth): debounce getToken() function
Problem:
The Identity team noticed a large spike in token refreshes for specific users.
One user would trigger refresh over 50 times within a few seconds.
Solution:
The telemetry showed that `getChatAuthState()` was being called many times in a
short period. This eventually triggered the token refresh logic many times, if the token was
expired.
The solution is to add a debounce to `getToken()` which calls the refresh logic.
- `debounce()` only accepts functions without any args, the refresh logic requires args
- `getToken()` will also load from disk is the token is not expired, so debouncing here
saves disk I/O as well.
The current debounce interval is 100 milliseconds, which based on telemetry should be enough to capture the barrage of calls.
Signed-off-by: nkomonen-amazon <[email protected]>1 parent df7a3b6 commit ce410ea
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
0 commit comments