Skip to content

[Backend] Make /health not report 503 when the indexer is disabled or cold-started #463

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

The /health endpoint (backend/src/routes/health.routes.ts) returns a single overall status and uses it for the HTTP code (200 vs 503). It treats the service as degraded whenever indexerLag > 60 seconds — but on a freshly deployed instance, or one where STREAM_CONTRACT_ID is intentionally unset (indexer disabled), the indexer state row is stale or absent and the endpoint reports 503 even though the API itself is perfectly healthy. Container orchestrators (Render/Docker, see render.yaml / docker-compose.yml) use health checks for liveness/readiness, so a perpetually-503 health check can cause restart loops or block traffic for a service that is actually up.

Splitting liveness (process up + DB reachable) from readiness/indexer-lag, or making the indexer-lag contribution conditional on the indexer being enabled, makes the health signal trustworthy.

Acceptance criteria

  • Distinguish core health (process + DB) from indexer freshness; do not return 503 purely because the indexer is disabled or has no state row yet.
  • Keep reporting indexerLag in the body for observability, but only let it force a non-200 status when the indexer is actually enabled (STREAM_CONTRACT_ID set) and lagging.
  • Optionally add a lightweight /health/live vs /health/ready split, or document the single-endpoint semantics clearly.
  • Add/extend a test covering: DB up + indexer disabled returns 200; DB down returns 503.

Files to touch

  • backend/src/routes/health.routes.ts
  • backend/tests/ (new or existing health test)

Out of scope

  • Prometheus / external monitoring integration.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksinfraCI/CD and infrastructure

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions