koajs / ratelimit

Rate limiter middleware
MIT License
485 stars 57 forks source link

Throw correct error when rate limit exceeded #36

Closed yelworc closed 6 years ago

yelworc commented 6 years ago

PR #34 accidentally changed behavior in the rate-limiting case by moving the headers variable to a local scope, causing the ctx.throw statement to throw an uncaught error. Fix that, and add a test line to ensure we're throwing the expected error going forward.

yelworc commented 6 years ago

Background: I have Raven set up to handle and report uncaught errors, hence updating koa-ratelimit to 4.1.0 resulted in error 500 instead of 429 when rate limiting hits.

haoxins commented 6 years ago

koa-ratelimit@4.1.1