Skip to content

Fix: Health check now verifies server response#4

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-19-health-check-response-verification
Open

Fix: Health check now verifies server response#4
echobt wants to merge 1 commit intomainfrom
fix/issue-19-health-check-response-verification

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 19, 2026

Summary

This change ensures the health check function properly validates the server response instead of only checking if a TCP connection and write operation succeeded.

Problem

The health() function in src/server/client.rs only verified that it could establish a TCP connection and write an HTTP request. It immediately returned true after a successful write without reading or validating the server response. This means a hung or malfunctioning server that accepts connections but never responds would still be reported as healthy, potentially causing cascading failures in systems relying on accurate health status.

Solution

Modified the health() function to:

  1. Send the HTTP GET /health request
  2. Read the HTTP status line from the response
  3. Parse the HTTP status code and verify it is in the 2xx success range
  4. Only return true if the server responds with a successful status code

This ensures that the health check accurately reflects whether the server is actually processing requests and responding correctly.

Testing

The fix follows the same HTTP response reading pattern used by the search() and embed_batch() methods in the same file, which have been working correctly. The health check will now return false if:

  • Connection fails
  • Write fails
  • Flush fails
  • Reading the response fails
  • The HTTP status code is not in the 200-299 range

Related Issue

Fixes PlatformNetwork/bounty-challenge#19

echobt added a commit that referenced this pull request Jan 19, 2026
…main--components--term-challenge

chore(main): release 0.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Health check does not verify server response

1 participant