fix(monitoring): serve cached credentialHealth so /healthz is not starved - #12533
Merged
diegosouzapw merged 1 commit intoSep 4, 2026
Conversation
GET /api/monitoring/health no longer rebuilds on every cache miss or runs live credential probes while answering scrapes. Serve the last payload immediately (stale-while-revalidate), read credentialHealth from the in-memory cache including stale rows, and yield the event loop between background probe batches so /healthz stays responsive. Closes #12532 Co-authored-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
This was referenced Sep 6, 2026
Merged
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…iegosouzapw#12533) Validado em lote numa worktree combinada com os 10 PRs desta leva sobre o tip de `release/v3.8.51`: `typecheck:core` limpo, `check-file-size` OK e **241/242** nos 29 arquivos de teste que os PRs tocam. A única "falha" não é falha: `tests/unit/autoCombo/strict-zero-cost-filter.test.ts` é um teste em estilo Vitest que eu incluí por engano na invocação do runner nativo do Node — ele quebra no import (`@vitest/runner`), não numa asserção. Ao investigar, descobri que esse arquivo não roda em nenhum dos dois runners hoje (o glob do `test:unit` não lista `autoCombo` e o `include` do Vitest só pega `.tsx` nessa pasta); é um problema pré-existente do repositório, sem relação com esta leva, e vou registrá-lo separadamente. O diegosouzapw#12636 conflitava apenas na lista de testes do `@omniroute/opencode-plugin/package.json`, de forma aditiva: o tip já tinha `models-fetcher.test.ts` (do diegosouzapw#12607, irmão desta mesma leva) e o diegosouzapw#12636 acrescenta `telemetry.test.ts`. Fiz a união dos dois lados (25 arquivos contra 24 de cada) em vez de escolher um, o que teria removido um arquivo da suíte do plugin em silêncio. Obrigado, @RaviTharuma.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/monitoring/health(management view) now serves the last cached payload immediately, including a stalecredentialHealthsummary. Credential probes stay on the background scheduler and yield the event loop between batches soGET /healthzis not starved under scrape load.diegosouzapw/omniroute:3.8.50still rebuilt the ~8KB monitoring payload on the request path (1s TTL miss), which blocked in-pod/healthz(~6s stall) and caused a 10s json-exporter scrapeTimeout (context deadline exceeded). No env var on 3.8.50 made that handler non-blocking.Related Issues
Validation
tests/unit/monitoring-health-cached-credential.test.ts,tests/integration/monitoring-health-cache.test.tsrelease/v3.8.51(1 commit ahead, 0 behind)Tests Added Or Updated
tests/unit/monitoring-health-cached-credential.test.ts— stale/cachedcredentialHealthis returned immediately; the health route does not import live probe entry points.tests/integration/monitoring-health-cache.test.ts— expired payload is served immediately (stale-while-revalidate); DELETE still forces a rebuild.Reviewer Notes
src/lib/credentialHealth/scheduler.tsand yield between batches.