-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Bug Description
When using the limiter middleware with SkipSuccessfulRequests: true and SkipFailedRequests: false, requests that return an error using fiber.NewErrorf(...) are not counted toward the rate limit.
How to Reproduce
- Run the app.
- Make a GET request to
http://localhost:3000/. - Observe the response is a 500 Internal Server Error.
- Repeat the request immediately.
- Notice that the request is not rate limited, even after exceeding the configured max
(Max: 1).
Expected Behavior
Since the route returns a 500 status, and SkipFailedRequests is set to false, the request should be counted toward the rate limit.
After one such request, further requests within the expiration window (60s) should be rate limited.
Fiber Version
v3.0.0-beta.5.0.20250727145615-b839032cf299
Code Snippet (optional)
package main
import (
"time"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/limiter"
)
func main() {
app := fiber.New()
app.Use(limiter.New(limiter.Config{
Max: 1,
Expiration: 60 * time.Second,
LimiterMiddleware: limiter.SlidingWindow{},
SkipSuccessfulRequests: true,
SkipFailedRequests: false,
DisableHeaders: true,
}))
app.Get("/", func(c fiber.Ctx) error {
return fiber.NewErrorf(fiber.StatusInternalServerError, "Error")
})
app.Listen(":3000")
}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.
Reactions are currently unavailable