Skip to content

fix(listener): exempt rate-limit metrics endpoint from rate limiting#163

Open
giftexceed wants to merge 1 commit into
Core-Foundry:mainfrom
giftexceed:fix/listener-rate-limit-metrics
Open

fix(listener): exempt rate-limit metrics endpoint from rate limiting#163
giftexceed wants to merge 1 commit into
Core-Foundry:mainfrom
giftexceed:fix/listener-rate-limit-metrics

Conversation

@giftexceed

Copy link
Copy Markdown

Summary

Fixes the listener's GET /api/rate-limit/metrics endpoint being throttled by the rate limiter it reports on.

The rate limiter ran on every request, including the metrics route. So once a client tripped its quota, requesting /api/rate-limit/metrics returned 429 instead of the metrics — exactly when an operator most needs to read them.

The fix parses the request URL before the limiter check and skips rate limiting for that observability route (a GET to /api/rate-limit/metrics). The metrics request is no longer counted against the quota, so reported totals stay accurate.

Why this matters for CI

This is one of two pre-existing test failures in the listener on main (unrelated to any contract/dashboard work) that make the CI / Listener job red. This PR fixes the rate-limiter.test.ts failure; the companion PR #162 fixes the events-server.test.ts failure. With both, all 321 listener tests pass.

Verification

npx jest src/api/rate-limiter.test.ts   →  16 passed (was 1 failing)
npx tsc --noEmit                         →  clean
full listener suite                      →  only the PR #162 test remains (fixed there)

GET /api/rate-limit/metrics was subject to the rate limiter itself, so a
client that had already exhausted its quota received 429 when trying to
read the metrics. Parse the request URL before the limiter check and skip
limiting for the metrics observability route.

Fixes the failing "provides rate limiting metrics via
GET /api/rate-limit/metrics" test in rate-limiter.test.ts, which made 3
events requests (tripping the limit) and then expected the metrics
endpoint to return 200.
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.

1 participant