Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [Bug]: Limiter middleware with pebble storage does not deduct remaining limit #3018

Open
3 tasks done
rngallen opened this issue May 30, 2024 · 0 comments
Open
3 tasks done

Comments

@rngallen
Copy link

rngallen commented May 30, 2024

Bug Description

If i use memory storage limiter middleware deduct remaining limit on each request
If I switch from memory storage to pebble middleware remaining is always Maximum - 1

How to Reproduce

package main

import "github.com/gofiber/fiber/v3"
import "log"

func main() {
  app := fiber.New()

  // Steps to reproduce

	// Create a pebble storage instance
	storage := pebble.New(pebble.ConfigDefault)

	// Limit 120 Request per user(IP) per Minutes
	app.Use(limiter.New(limiter.Config{
		// Maximium number of requests
		Max:          60,
		Expiration:   1 * time.Minute,
		KeyGenerator: func(c *fiber.Ctx) string { return c.Get("X-Forwared-For") },
		Storage:      storage,
	}))

app.Get("/test", func(c *fiber.Ctx) error {return c.SendString("Test")})

  log.Fatal(app.Listen(":3000"))


}

Expected Behavior

Remaining limit should be deducted on each request

Fiber Version

2.52.4

Code Snippet (optional)

package main

import "github.com/gofiber/fiber/v3"
import "log"

func main() {
  app := fiber.New()

  // Steps to reproduce

	// Create a pebble storage instance
	storage := pebble.New(pebble.ConfigDefault)

	// Limit 120 Request per user(IP) per Minutes
	app.Use(limiter.New(limiter.Config{
		// Maximium number of requests
		Max:          60,
		Expiration:   1 * time.Minute,
		KeyGenerator: func(c *fiber.Ctx) string { return c.Get("X-Forwared-For") },
		Storage:      storage,
	}))

app.Get("/test", func(c *fiber.Ctx) error {return c.SendString("Test")})

  log.Fatal(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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant