Skip to content

Harden health endpoint: typed responses, timeouts, and readiness vs liveness split #402

Description

@Wilfred007

What

Improve backend/src/controllers/healthController.ts: remove the any types on the redis client and statusReport, add per-dependency timeouts, and split into a lightweight liveness probe and a dependency-checking readiness probe.

Why

The current handler builds an untyped statusReport: any and checks Postgres, Redis, and Horizon inline. Without timeouts, a slow dependency can hang the health check; without a liveness/readiness split, orchestrators can't distinguish 'process alive' from 'ready to serve traffic', causing unnecessary restarts or routing to a not-ready instance.

Scope

In scope:

  • Define typed interfaces for the health report and each dependency status.
  • Wrap each dependency check in a bounded timeout.
  • Add GET /health/live (process up, no deps) and keep GET /health (or /health/ready) for full dependency checks.
  • Return 503 when a critical dependency is down.

Out of scope:

  • Adding new monitored dependencies.

Acceptance criteria

  • No any types remain in the health controller.
  • A hung dependency causes the check to fail fast within the timeout, not hang.
  • Liveness and readiness are separately reachable.
  • Tests cover healthy, degraded, and timeout paths.

Technical context

  • File: backend/src/controllers/healthController.ts (redis: any, statusReport: any).
  • Existing tests: backend/src/controllers/__tests__/healthController.test.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions