Skip to content

Reset rate limiter state when merchant plan is upgraded#238

Open
agnesadoga-creator wants to merge 1 commit into
FX-GENE:mainfrom
agnesadoga-creator:fix/16-rate-limit-plan-upgrade
Open

Reset rate limiter state when merchant plan is upgraded#238
agnesadoga-creator wants to merge 1 commit into
FX-GENE:mainfrom
agnesadoga-creator:fix/16-rate-limit-plan-upgrade

Conversation

@agnesadoga-creator

Copy link
Copy Markdown

Closes #16

Problem

Merchants who upgraded their plan kept hitting the old, lower rate limit because cached limiter state was not invalidated on upgrade.

Fix

RateLimiterService now caches the resolved per-tier limit alongside the usage counter, keyed by merchant id (limitCache). Previously reset() only cleared the request counter, so once a limit was resolved for a merchant it stayed cached forever even after a plan change. reset() now also evicts the cached tier limit, and PlanService.upgradePlan() calls it on every upgrade so the next request recomputes the limit from the merchant's new tier instead of reusing the stale one.

Testing

Reviewed by inspection (no local build/test run per task scope - dependencies not installed). Existing test/rate-limiter.spec.ts still passes by inspection: reset() continues to zero out the usage counter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate limiter does not reset on merchant plan upgrade

1 participant