Skip to content

fix: add native lifecycle-aware health endpoint - #7852

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.49from
RaviTharuma:fix/7848-native-healthz
Jul 20, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.49from
RaviTharuma:fix/7848-native-healthz

Conversation

@RaviTharuma

Copy link
Copy Markdown
Contributor

Summary

  • add a native unauthenticated GET/HEAD /healthz endpoint
  • report 503 during startup and graceful shutdown, and 200 only after initialization
  • bypass centralized auth without database or provider dependencies
  • add focused lifecycle and auth-matcher regression tests

Validation

  • node --import tsx/esm --test tests/unit/healthz-route.test.ts
  • npm run typecheck:core
  • focused ESLint and git diff --check

Closes #7848

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new /healthz endpoint to track and expose the server's lifecycle phases (starting, ready, and stopping) using a global state manager. It integrates lifecycle hooks into the Node.js instrumentation startup and graceful shutdown processes, and adds comprehensive unit tests. The reviewer points out a critical issue where the /healthz route handler might be statically optimized and cached by Next.js at build time, and suggests adding export const dynamic = "force-dynamic"; to ensure it is always executed dynamically at runtime.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/app/healthz/route.ts
@RaviTharuma

Copy link
Copy Markdown
Contributor Author

Addressed the static-optimization finding in b5481c9: /healthz now exports dynamic = "force-dynamic", and the lifecycle regression test asserts the route remains dynamic. Focused tests, core typecheck, ESLint, Prettier, and diff checks pass.

@RaviTharuma
RaviTharuma force-pushed the fix/7848-native-healthz branch from b5481c9 to d95c736 Compare July 20, 2026 11:28
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for this — clean, focused implementation that matches what #7848 asked for closely: unauthenticated /healthz, 503 during start/stop, 200 only once registerNodejs() finishes, zero DB/provider I/O at request time, and a nice regression test that proves the auth-bypass claim against the real Next.js middleware matcher instead of just asserting on a string.

I ran the PR's test in isolation and it's 3/3 green; the CI red on this PR (Fast Quality Gates, ESLint, Unit Tests fast-path, dast-smoke) all trace back to a pre-existing base issue unrelated to this diff — ReferenceError: TICK_MS is not defined in src/lib/tokenHealthCheck.ts:285, reproducible on release/v3.8.49 before your commit — so none of that is on you; we'll land the base fix separately and this should go green on rebase.

A couple of small optional nits, non-blocking:

  • src/app/api/health/ping/route.ts (same category of endpoint in this repo) explicitly sets export const dynamic = "force-dynamic";. Next 16 already defaults GET route handlers to dynamic, so this probably isn't a live bug, but matching that convention would be cheap insurance against ever baking the 503-during-startup response into a build-time cache.
  • The issue asked for "documented readiness/liveness semantics" — a short docs note on the /healthz contract would close that out fully.
  • A changelog.d/features/7848-native-healthz.md fragment per this repo's changelog convention.

None of these block the merge; happy to add them directly if you'd rather not touch the branch again.

@diegosouzapw
diegosouzapw merged commit 916ccdd into diegosouzapw:release/v3.8.49 Jul 20, 2026
5 checks passed
@diegosouzapw

Copy link
Copy Markdown
Owner

Merged — thanks @RaviTharuma! The lifecycle-aware /healthz endpoint is a clean addition and the test coverage made it an easy call. Validated in the local merge-train (14-PR combined tree, full unit suite + vitest green) on tomni-proxmox-113 @ 0fda37bb4fdb26ba1345fd7b4cac44fbe235cda4, then squash-merged.

@diegosouzapw diegosouzapw mentioned this pull request Jul 23, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
* fix: add native health endpoint

* fix: keep health endpoint dynamic

---------

Co-authored-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
@RaviTharuma
RaviTharuma deleted the fix/7848-native-healthz branch September 23, 2026 19:38
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
* fix: add native health endpoint

* fix: keep health endpoint dynamic

---------

Co-authored-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
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.

feat(api): add a native lightweight /healthz endpoint for orchestrators

2 participants