question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Points not decreasing

See original GitHub issue

I’m using nore-rate-limiter-flexible via example memory code within my stack to check specific requests, but the remaining points are never decreasing. (even if I spam multiple per second)

Code:

const rate = new RateLimiterMemory({points: 5, duration: 1})

rate
.consume(req.ip, 2)
.then((e) => {
    console.log('ip', req.ip)
    console.log('response', e)
})
.catch(() => {
  console.error('rate limit')
})

Response:

ip: ::1
response: {
  remainingPoints: 3,
  msBeforeNext: 1000,
  consumedPoints: 2,
  isFirstInDuration: true
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tre-devcommented, Jan 5, 2021

Okay, I think I got the problem. I recreated the RateLimiter every request to be able to set dynamic options, which resets the memory. I’m setting different versions now once on startup. Thanks for the help!

0reactions
ShekharBhabadcommented, Jun 9, 2022

Hi, I am also facing the same issue when we are trying to use memory code instead of the share memory (redis/memcached) points are not getting decreased even when I am hitting a particular endpoint multiple times using ab testing .

@tre-dev what do you meant when you said -> “I recreated the RateLimiter every request to be able to set dynamic options, which resets the memory. I’m setting different versions now once on startup”

what changes will I have to make ?

I am always getting this in response { remainingPoints: 50, msBeforeNext: 1000, consumedPoints: 50, isFirstInDuration: true }

so basically its treating all the requests as first requests (isFirstInDuration is always true) and never decreasing points after first time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

About point reduction - New York DMV
Point reduction does not prevent or cancel a mandatory revocation or suspension for violations such as DWI, DWAI, or three speeding violations within...
Read more >
Visual glitch? Summoning points not draining : r/runescape
It seems that the summoning points bar is all messed up atm. ... Restore over time, replenished by Summoning Pots, cost reduced by...
Read more >
Points and Points Reduction | Georgia Department of Driver ...
Offense Code Conviction Points §40‑6‑397 Aggressive Driving 6 Points §40‑6‑390 Reckless Driving 4 Points §40‑6‑163 Unlawful Passing School Bus 6 Points
Read more >
Mortgage Points: What are they and how do they work?
Mortgage points are basically a way to lower your mortgage's interest rate — for a fee. Here's how they work and when to...
Read more >
What Are Points in the Stock Market? - Investopedia
Points refer only to the dollar amount that has changed, not the percentage. Two stocks can lose the same number of points but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found