Skip to content

fix(client): return false from healthCheck on non-2xx responses - #258

Merged
edenreich merged 1 commit into
mainfrom
fix/issue-256
Sep 25, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/issue-256

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #256

Summary

healthCheck() resolved true for any HTTP status because fetch resolves for every response, including non-2xx ones. It now returns response.ok, so a 502/503 from an ingress or load balancer in front of a stopped gateway, or a 404 from a misconfigured baseURL, is reported as unhealthy. This matches the OpenAPI spec's contract for GET /health ("Returns a 200 status code if the service is healthy") and the README usage. A rejected fetch (network failure) still resolves false.

Changes

  • src/client.ts: healthCheck() now returns response.ok instead of unconditionally returning true after a resolved fetch
  • tests/client.test.ts: add a regression test covering a 503 response using a real Response object, mirroring the issue's reproduction
  • No openapi.yaml changes; generated types are untouched

Tests

  • npm test: 43 passed, including the new "should return false when API answers with an HTTP error status" case
  • npm run lint and npm run format: clean
  • Pre-commit hooks (format, lint, build, test) passed on commit

Docs

healthCheck() resolved true for any HTTP status because fetch resolves regardless of status. It now returns response.ok, so 502/503 from an ingress in front of a stopped gateway or a 404 from a misconfigured baseURL report unhealthy, matching the spec's 200-if-healthy contract.

Add a regression test covering a 503 response.
@inference-gateway-maintainer
inference-gateway-maintainer Bot marked this pull request as ready for review September 25, 2026 22:51
@edenreich
edenreich merged commit b2eefa7 into main Sep 25, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-256 branch September 25, 2026 22:52
inference-gateway-releaser Bot added a commit that referenced this pull request Sep 26, 2026
## [0.25.2](v0.25.1...v0.25.2) (2026-09-26)

### 🐛 Bug Fixes

* **client:** return false from healthCheck on non-2xx responses ([#258](#258)) ([b2eefa7](b2eefa7))

### 📚 Documentation

* **readme:** document healthCheck false on non-2xx and network failures ([#260](#260)) ([2970b20](2970b20))
* **readme:** fix Tool Calls example typing and gateway intro link ([#259](#259)) ([e3d38f0](e3d38f0))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.278 -> 2.1.280 ([#254](#254)) ([a3c5aaa](a3c5aaa))
* **deps:** bump infer CLI v0.205.3 -> v0.208.0 ([#255](#255)) ([f2314da](f2314da))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.25.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] healthCheck() returns true when the gateway answers with an HTTP error status

1 participant