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.

Patch version 0.2.12 introduces a breaking change

See original GitHub issue

The new version has an updated method to calculate timestamps: https://github.com/peterkhayes/rolling-rate-limiter/commit/6e6f214bde915bcc419da8eeaab3b948d6d87a08#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R279

The final resultant current timestamp value is significantly different to the previous one. (Almost ~2000x smaller).

Current:

> hr = process.hrtime()
[ 791879, 55186464 ]
> (hr[0] * 1e9 + hr[1]) / 1e3
791879055186.464

Previous (loaded up the library functions already):

> delta = milliseconds * Math.pow(10, 3) - toMicroseconds(hrtime);
1637029532854004

On its own, from a “fresh start” this would seem fine. But in my use case, the rate limiter is based on redis and is separate from the node application. As a result, after this update, all rate limit checks failed, since at https://github.com/peterkhayes/rolling-rate-limiter/blob/master/src/index.ts#L109 , the calculated value ends up being negative.

This is due to redis storing an event from a previous “block” with the older (and numerically much larger) timestamp.

I can’t really think of a good way to fix this, since there is no versioning in the redis entry, to actively convert from one format to the other.

Reverting https://github.com/peterkhayes/rolling-rate-limiter/pull/60 would fix it in some specific use cases, but of course it would mean someone on the newer timestamp who is relying on blocking on minDifference would face difficulties too…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ckcr4lyfcommented, Dec 1, 2021

Thanks for acknowledging and reverting the change. Cheers

2reactions
peterkhayescommented, Nov 29, 2021

I reverted to use a library again and published as 0.2.13. The reason I didn’t make a new minor version is that I don’t want people to update to 0.2.12 by mistake.

Once again I’m sorry about this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems with the Magic Zero · Issue #221 · semver ... - GitHub
Additive changes may be introduced by +incrementing the patch version. Breaking changes may be introduced by +incrementing the minor version ...
Read more >
Breaking Bad? Semantic Versioning and Impact of Breaking ...
<patch>, where major, minor, and patch are non-negative integers. A change in the major version signals the possible introduction of ...
Read more >
Firenvim version history - 25 versions - Firefox Add-ons
Breakage caused by incorrect parsing of msgpack encodings introduced in recent ... Neovim plugin has been fixed after neovim breaking change (35caecb)
Read more >
azure-cli-redis 0.4.4 - PyPI
az redis create : Support for Availability Zones and Minimum TLS Version. BREAKING CHANGE: Removed 'az redis update-settings' and 'az redis list-all' ...
Read more >
Version history - Seeds - Sprout Social
Change Log. 12.21.1. Patch Changes. e0e4fc78: Storybook addon-essentials has been moved to devDependencies rather than dependencies since it is only used ...
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