Repository navigation
Conversation
Add GET/HEAD /api/health, an unauthenticated endpoint for uptime monitors (e.g. StatusCake). It answers 200 when every check passes and 503 otherwise, with a per-dependency JSON breakdown: - database (SELECT 1) and redis (PING) - per network: chronik reachability (blockchainInfo), chronik WebSocket open, and ingestion freshness: chronik's tip must not be more than one block ahead of the newest block delivered over the WebSocket, which catches the server being up but no longer receiving new txs Each check times out after 3s, results are cached for 10s with concurrent callers sharing one run, and errors are reduced to "timeout"/"unavailable" so nothing internal leaks. Networks under maintenance are skipped. Also add a public /status page that shows the same report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019G564i2sNiHJYQR95m8zGq
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…ighbouring code Move the timeout import, the WS ready-state constant and the ChronikHealth type so they don't touch the same lines as the chronik-down changes, and reset the WS block height after the connection bookkeeping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019G564i2sNiHJYQR95m8zGq
This branch has not been deployed
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.
Related to #1063
Related to #769
Description
Adds a public, unauthenticated health check that an uptime monitor such as StatusCake can watch, plus a public
/statuspage that shows the same information.GET /api/health(alsoHEAD; reachable as/healthtoo through the existing rewrite) answers 200 when every check passes and 503 when any fails, with a JSON breakdown:database:SELECT 1redis:PINGecash,bitcoincash):chronik: the indexer answersblockchainInfo(one call, no retries); reportstipHeightwebsocket: the chronik WebSocket that delivers new txs is openingestion: chronik's tip is at most one block ahead of the newest block delivered over that WebSocket (blocksBehind). This catches the server being up but no longer pulling in new txs (Have the server be able to recover automatically when it's "up" but can't pull in new txs #812). The baseline is set from chronik's tip on the first check after each WS (re)connect, so blocks missed while the WS was down don't keep it failing after a reconnect.Each check times out after 3s, so a hung dependency can't hang the endpoint (Redis is configured with
maxRetriesPerRequest: nulland would otherwise queue forever). Results are cached in memory for 10s, and concurrent callers share one run, so frequent polling is cheap. Error details are reduced totimeout/unavailable, with the real error logged server-side, so connection strings and hostnames don't leak. Networks listed innetworksUnderMaintenanceare skipped and count as healthy. The response hasCache-Control: no-store./status(#769) is a small public page, viewable logged in or not, that polls/api/healthevery 30s and lists Database / Cache / each network as Operational, Outage or Maintenance, with a short reason.The endpoint is documented in the README under "Health checks and monitoring".
Code changes:
services/healthService.ts: checks, timeouts, cachepages/api/health/index.ts: routeChronikBlockchainClient.getHealth()/isWsConnected(), andMultiBlockchainClient.getChronikHealth(). The client now tracks the newest WS block height.utils/timeout.ts:withTimeouthelpercomponents/Status,pages/status, and/statusadded to the public URLs in_app.tsxping()added to the mocked Redis client used in testsTest plan
make github-test-unit: 20 suites / 424 tests pass.tests/unittests/healthService.test.tscovers:chronikService.test.ts:getHealthreports the tip and WS stategetHealthfails cleanly while the client isn't initializedtsc --noEmitreports no new errors in the changed files./api/healthon staging, stop Redis or block a chronik host, and confirm a 503 with the matching check failing. Open/statuslogged out.Remarks
https://<host>/api/healthand alert on non-2xx.Generated by Claude Code