From 3ce97166292621ab3178579606d7a69dd7456aed Mon Sep 17 00:00:00 2001 From: Samantha Date: Wed, 25 Oct 2023 12:33:29 -0400 Subject: [PATCH] Revert accidental removal. --- ratelimits/limiter.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ratelimits/limiter.go b/ratelimits/limiter.go index 6e4b074199e..51f8119dcc5 100644 --- a/ratelimits/limiter.go +++ b/ratelimits/limiter.go @@ -136,6 +136,10 @@ func (l *Limiter) Check(ctx context.Context, bucket BucketWithCost) (*Decision, return nil, err } + if bucket.cost > limit.Burst { + return nil, ErrInvalidCostOverLimit + } + // Remove cancellation from the request context so that transactions are not // interrupted by a client disconnect. ctx = context.WithoutCancel(ctx) @@ -171,6 +175,10 @@ func (l *Limiter) Spend(ctx context.Context, bucket BucketWithCost) (*Decision, return nil, err } + if bucket.cost > limit.Burst { + return nil, ErrInvalidCostOverLimit + } + start := l.clk.Now() status := Denied defer func() {