Commit 65db489
authored
fix(poll): exponential backoff on 401 Unauthorized (#163)
## Summary
When the Hub returns `401 Unauthorized` during a poll round (token
expired or revoked), the poll loop kept hammering `/api/tree` every
`poll_interval` seconds with the same invalid token, generating noise
and unnecessary load.
This adds an exponential backoff specific to 401s in
`src/virtual_fs/poll.rs`:
- Track `auth_backoff_exp`, incremented each round that observes at
least one `Error::Hub { status: Some(401), .. }`.
- Next sleep becomes `interval * 2^exp`, capped at `2^6` (so ~32 min
with a 30 s base interval).
- Exponent resets to 0 as soon as a poll round completes without any
401, so recovery (e.g. token refresh) is immediate.
- Other failures (504s, network errors, etc.) keep behaving exactly as
before, no backoff applied.1 parent 7c47438 commit 65db489
1 file changed
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | | - | |
| 40 | + | |
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
| |||
49 | 58 | | |
50 | 59 | | |
51 | 60 | | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
58 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
59 | 72 | | |
60 | 73 | | |
61 | 74 | | |
62 | 75 | | |
63 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
64 | 87 | | |
65 | 88 | | |
66 | 89 | | |
| |||
0 commit comments