Commit edbbca3
Fix edge cases: sub-second rate limit durations and UTF-8 BOM
- Primary rate limit: compute time.Until(resetTime) once and check the
rounded result is >0 before showing 'Retry after X'. This avoids a
TOCTOU race between the After(time.Now()) guard and the subsequent
time.Until call, and prevents showing 'Retry after 0s.' when the
reset time is imminent.
- Secondary rate limit: round RetryAfter first, then check >0.
Previously, a RetryAfter of e.g. 200ms would pass the >0 guard
but format as 'Retry after 0s.' after rounding.
- Add tests for both sub-second edge cases.
- Remove UTF-8 BOM accidentally introduced in error_test.go by
.NET WriteAllText with the default UTF8 encoding.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 52d8383 commit edbbca3
2 files changed
Lines changed: 49 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | | - | |
171 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
566 | 584 | | |
567 | 585 | | |
568 | 586 | | |
| |||
580 | 598 | | |
581 | 599 | | |
582 | 600 | | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
583 | 619 | | |
584 | 620 | | |
585 | 621 | | |
| |||
0 commit comments