alovajs / alova

Workflow-Streamlined next-generation request tools. Extremely streamline API integration workflow, just one step
https://alova.js.org
MIT License
2.96k stars 108 forks source link

fix: `msBeforeNext` not reduce in server/rate-limit (#462) #508

Closed MeetinaXD closed 3 months ago

MeetinaXD commented 3 months ago

相关 Issue / Related Issue

close #462

这个 PR 是什么类型?/ What type of PR is this?

这个 PR 做了什么?/ What does this PR do?

fix: decrease msBeforeNext value in real time when points exceed limit

文档 / Docs

when implement limiter by extending class RateLimiterStoreAbstract, the expireTime should not be updated in every _upsert action.

here's the key: If the old expireTime is later than now, just keep this value and do not update.

the value msBeforeNext is calculated by the last record written to the store, which contains expireTime. that's why this value will not reduce in previous version because it always update the expireTime.

测试 / Testing

ALL tests passed.

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: f117787628ae49c283d3c3be6dfa4a3f1344e10d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----- | ----- | | alova | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR