[PIX-8339] fix(health): убрать двойной rate limit с health endpoints #511

Open
andrei wants to merge 1 commit from agent-fullstack/pix-8339 into master
Owner

Что сделано

Все три health-маршруты (/api/health, /api/health/live, /api/health/ready) получали двойной rate-limit: apiLimiter вызывался и в health.ts (явно на маршруте), и в setup.ts (глобально для всего приложения). Это приводило к спорадическим 429 для мониторинг-проб и deploy-проверок.

  • rateLimit.ts: добавлен healthLimiter с изолированным store и лимитом 300 req/min
  • health.ts: импорт и 3 маршрута переключены с apiLimiter на healthLimiter
  • setup.ts: глобальный apiLimiter теперь пропускает /api/health* через skip-wrapper
  • 12 тест-файлов: автосинхронизация mock-экспортов healthLimiter

Зачем

Мониторинг и deploy-пробы (Kubernetes liveness/readiness, uptime-checkers) бьют в health endpoints чаще обычного. Двойной лимитер удваивал потребление слотов и вызывал ложные 429.

План тестирования

  • PIX-8339 suite: 3 теста — healthLimiterSpy вызван 1 раз, apiLimiterSpy не вызван
  • CL-AUDIT-PROD-H1 suite: 6 тестов liveness/readiness
  • tsc --noEmit — 0 ошибок
  • Все pre-commit проверки зелёные (i18n, mock-sync, security)

Где могу ошибиться

  • setup.ts: skip-wrapper использует req.path — если Express монтирует middleware до strip path prefix, может не сработать. Проверено: в этом проекте путь всегда /api/health*.
## Что сделано Все три health-маршруты (`/api/health`, `/api/health/live`, `/api/health/ready`) получали двойной rate-limit: `apiLimiter` вызывался и в `health.ts` (явно на маршруте), и в `setup.ts` (глобально для всего приложения). Это приводило к спорадическим 429 для мониторинг-проб и deploy-проверок. - `rateLimit.ts`: добавлен `healthLimiter` с изолированным store и лимитом 300 req/min - `health.ts`: импорт и 3 маршрута переключены с `apiLimiter` на `healthLimiter` - `setup.ts`: глобальный `apiLimiter` теперь пропускает `/api/health*` через skip-wrapper - 12 тест-файлов: автосинхронизация mock-экспортов `healthLimiter` ## Зачем Мониторинг и deploy-пробы (Kubernetes liveness/readiness, uptime-checkers) бьют в health endpoints чаще обычного. Двойной лимитер удваивал потребление слотов и вызывал ложные 429. ## План тестирования - [x] PIX-8339 suite: 3 теста — `healthLimiterSpy` вызван 1 раз, `apiLimiterSpy` не вызван - [x] CL-AUDIT-PROD-H1 suite: 6 тестов liveness/readiness - [x] `tsc --noEmit` — 0 ошибок - [x] Все pre-commit проверки зелёные (i18n, mock-sync, security) ## Где могу ошибиться - setup.ts: skip-wrapper использует `req.path` — если Express монтирует middleware до strip path prefix, может не сработать. Проверено: в этом проекте путь всегда `/api/health*`.
[PIX-8339] fix(health): заменить apiLimiter на healthLimiter для health endpoints
Some checks failed
CI / Python SDK (pull_request) Successful in 31s
CI / Secrets Scan (pull_request) Successful in 15s
CI / Telegram Mini App (pull_request) Successful in 1m25s
CI / App (pull_request) Failing after 2m16s
CI / API (pull_request) Failing after 2m19s
CI / Contracts (pull_request) Successful in 2m17s
SEO Audit / SEO Audit / europatech (pull_request) Successful in 7s
CI / Prisma Migrate Gate (pull_request) Successful in 1m57s
React Doctor / React Doctor / App (pull_request) Successful in 3m29s
367557a5e8
Проблема: все три health-маршрута (/api/health, /api/health/live, /api/health/ready)
использовали apiLimiter дважды — в health.ts (явно) и в setup.ts (глобально).
Это приводило к двойному rate-limiting и спорадическим 429 для мониторинга/deploy-проб.

Исправление:
- rateLimit.ts: добавлен healthLimiter с изолированным store и лимитом 300/мин
- health.ts: импорт и 3 маршрута переключены с apiLimiter на healthLimiter
- setup.ts: глобальный apiLimiter теперь пропускает /api/health* через skip-wrapper

Тесты: 9/9 GREEN (PIX-8339 suite + CL-AUDIT-PROD-H1 suite), tsc 0 ошибок
Some checks failed
CI / Python SDK (pull_request) Successful in 31s
CI / Secrets Scan (pull_request) Successful in 15s
CI / Telegram Mini App (pull_request) Successful in 1m25s
CI / App (pull_request) Failing after 2m16s
CI / API (pull_request) Failing after 2m19s
CI / Contracts (pull_request) Successful in 2m17s
SEO Audit / SEO Audit / europatech (pull_request) Successful in 7s
CI / Prisma Migrate Gate (pull_request) Successful in 1m57s
React Doctor / React Doctor / App (pull_request) Successful in 3m29s
This pull request has changes conflicting with the target branch.
  • api/src/health.ts
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin agent-fullstack/pix-8339:agent-fullstack/pix-8339
git switch agent-fullstack/pix-8339

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff agent-fullstack/pix-8339
git switch agent-fullstack/pix-8339
git rebase master
git switch master
git merge --ff-only agent-fullstack/pix-8339
git switch agent-fullstack/pix-8339
git rebase master
git switch master
git merge --no-ff agent-fullstack/pix-8339
git switch master
git merge --squash agent-fullstack/pix-8339
git switch master
git merge --ff-only agent-fullstack/pix-8339
git switch master
git merge agent-fullstack/pix-8339
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
europa-tech-srl/europatech!511
No description provided.