Skip to content

P1: Add readiness probe distinct from liveness (#169) - #187

Open
dkijania wants to merge 1 commit into
mainfrom
feat/readiness-probe
Open

P1: Add readiness probe distinct from liveness (#169)#187
dkijania wants to merge 1 commit into
mainfrom
feat/readiness-probe

Conversation

@dkijania

Copy link
Copy Markdown
Contributor

What & why

Part of the production-readiness epic (#163). Closes #169.

/healthcheck is Yoga's built-in liveness check — it only confirms the process is serving HTTP, not that the database is reachable. An orchestrator therefore keeps routing traffic to an instance whose Postgres is down.

Changes

  • New /readiness endpoint (src/server/readiness.ts) that pings the DB and returns 200 when it answers, 503 otherwise.
  • ping() added to the database adapter — runs SELECT 1, resolves false instead of throwing.
  • The readiness plugin is prepended to the plugin list so probes short-circuit before any other request hook (e.g. rate limiting) can interfere.

Probe usage

Endpoint Probe Checks
/healthcheck liveness process is up (no DB)
/readiness readiness DB reachable (SELECT 1)

A node with an unreachable DB reports not-ready (stops getting traffic) while staying live (not needlessly restarted).

Testing

  • npm run build — clean
  • npm run test:unit — all pass (200/503 end-to-end through Yoga; confirms normal GraphQL requests are not intercepted)
  • npm run lint — clean
  • npx prettier --debug-check . — exit 0

🤖 Generated with Claude Code

`/healthcheck` is Yoga's built-in liveness check — it only confirms the process
is serving HTTP, not that the database is reachable. An orchestrator therefore
keeps routing traffic to an instance whose Postgres is down.

Add a `/readiness` endpoint that pings the database (`SELECT 1`) and returns 200
when it answers, 503 otherwise. A lightweight `ping()` is added to the database
adapter (resolves false instead of throwing). The readiness plugin is prepended
to the plugin list so probes short-circuit before any other request hook (e.g.
rate limiting) can interfere.

Use `/healthcheck` for the Kubernetes liveness probe and `/readiness` for the
readiness probe: a node with an unreachable DB reports not-ready (stops getting
traffic) while staying live (not needlessly restarted). Docs updated; unit tests
cover 200/503 and confirm normal GraphQL requests pass through untouched.

Closes #169.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSuak9smCHbp4N17xjjLF6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 Strongly recommended before GA production-readiness Work toward making the API production-ready / publicly available

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P1: Add readiness probe (DB ping) distinct from liveness

1 participant