-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
Bug Description
The rate limiter middleware stops allowing requests once the limit is reached and never resets, even after the expiration window has passed.
How to Reproduce
goapp.Use(limiter.New(limiter.Config{
Max: 20,
Expiration: 30 * time.Second,
}))Expected Behavior
After 20 requests within 30 seconds, subsequent requests should be rate limited (429). Once the 30-second window expires, requests should succeed again (200).
Logs:
{"level":"info","ts":1763885420.00698,"caller":"v2@v2.1.6/zap.go:106","msg":"Success","ip":"127.0.0.1","latency":"33.893µs","status":200,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885430.0723326,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"7.067µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885440.1590369,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"12.539µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885450.2498455,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.84µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885460.6493433,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"8.911µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885470.7410114,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"6.363µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885480.8387995,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"6.318µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885490.9188917,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.812µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885500.9927847,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.594µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885511.0701776,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"6.188µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885521.1578481,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.618µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885531.2473729,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"6.843µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885541.3068976,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.966µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885551.4161906,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.991µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885561.528288,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.898µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885571.6134698,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"7.829µs","status":429,"method":"GET","url":"/ready"}
{"level":"warn","ts":1763885581.7208788,"caller":"v2@v2.1.6/zap.go:106","msg":"Client error","ip":"127.0.0.1","latency":"5.463µs","status":429,"method":"GET","url":"/ready"}
Fiber Version
v2.52.9
Code Snippet (optional)
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.