Skip to content

feat(node): standalone health and readiness helpers - #545

Merged
kartikeya-27 merged 4 commits into
masterfrom
feat/node-health-helpers
Jul 25, 2026
Merged

feat(node): standalone health and readiness helpers#545
kartikeya-27 merged 4 commits into
masterfrom
feat/node-health-helpers

Conversation

@pratyush618

@pratyush618 pratyush618 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #519.

Health and readiness were reachable only through the dashboard route table, so
a deployment without a dashboard had no probe to call. New src/health.ts
holds them standalone:

  • checkHealth(){ status: "ok" } — liveness, never touches storage.
  • checkReadiness(queue){ status: "ready" | "degraded", checks } over
    storage, workers, and worker resources. Never throws: a failing dependency is
    reported as "error: <message>" in checks and degrades the status, so a
    probe endpoint can always answer.
  • resourceStatus(queue) — per-resource health aggregated across every live
    worker's heartbeat, moved here from the dashboard handlers (readiness needs
    it, and a core module shouldn't reach into dashboard/).

Typed returns (HealthReport, ReadinessReport, ReadinessChecks,
WorkersCheck, ResourcesCheck, ResourceStatusEntry), all exported from the
package root. Payload shapes are unchanged, so the dashboard JSON contract
holds.

Three call sites now share the one implementation instead of carrying their
own: the dashboard's /health and /readiness, the KEDA scaler server's
/health (previously an inline literal), and the Express/Fastify REST table,
which gains health, readiness, and resources routes under the same route
names the other SDK shells use. Readiness answers 503 when degraded so
orchestrators drain the instance. dashboard/handlers/ops.ts keeps only the
scaler payload and re-exports the helpers, leaving the dashboard route table
untouched.

Docs: a Health & readiness section in the node monitoring guide, the probe rows
in the Express/Fastify route tables, and a no-router snippet on the shared
deployment page.

Testing

  • pnpm test — 609 tests across 86 files, all passing (9 new health tests, 1
    new REST probe-route test).
  • pnpm typecheck, pnpm lint, docs lint + typecheck clean.

Summary by CodeRabbit

  • New Features
    • Added standalone health, readiness, and resource-status checks for Node applications, including safe readiness reporting.
    • Exposed /health, /readiness, and /resources operational endpoints across REST, dashboard, scaler, Express, and Fastify integrations.
  • Documentation
    • Updated monitoring and integration guides with probe semantics, response formats, and custom-route/load-balancer examples.
  • Tests
    • Added and expanded integration and unit tests for health/readiness outcomes, degraded behavior, and resource aggregation (including malformed payload handling).

Probes usable without a dashboard; the dashboard and scaler now call them.
Adds health/readiness/resources to the Express and Fastify route table.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 581f7a3e-6a7a-4540-8c92-e0a716a1ec66

📥 Commits

Reviewing files that changed from the base of the PR and between 31141c8 and 9eefe02.

📒 Files selected for processing (1)
  • docs/content/docs/node/guides/observability/monitoring.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/content/docs/node/guides/observability/monitoring.mdx

📝 Walkthrough

Walkthrough

The Node SDK adds standalone checkHealth(), checkReadiness(queue), and resourceStatus(queue) helpers, exports their types, wires them into REST, dashboard, and scaler endpoints, adds coverage, and updates integration and deployment documentation.

Changes

Health probe implementation

Layer / File(s) Summary
Health and resource status helpers
sdks/node/src/health.ts, sdks/node/test/observability/health.test.ts
Adds liveness, readiness, resource aggregation, error reporting, and malformed-payload handling with tests.
Probe endpoint wiring and exports
sdks/node/src/index.ts, sdks/node/src/contrib/rest.ts, sdks/node/src/dashboard/*, sdks/node/src/scaler/server.ts, sdks/node/test/integrations/rest.test.ts
Exports the helpers and exposes /health, /readiness, and /resources; degraded readiness returns HTTP 503.
Probe integration documentation
docs/content/docs/node/guides/integrations/*, docs/content/docs/node/guides/observability/monitoring.mdx, docs/content/docs/shared/guides/operations/deployment.mdx
Documents route availability, report semantics, resource checks, and custom Express probe routes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ProbeEndpoint
  participant HealthHelpers
  participant Queue
  Client->>ProbeEndpoint: Request /health or /readiness
  ProbeEndpoint->>HealthHelpers: checkHealth() or checkReadiness(queue)
  HealthHelpers->>Queue: stats() and listWorkers()
  Queue-->>HealthHelpers: Queue and worker results
  HealthHelpers-->>ProbeEndpoint: HealthReport or ReadinessReport
  ProbeEndpoint-->>Client: JSON response with status 200 or 503
Loading

Possibly related PRs

  • ByteVeda/taskito#378: Adds the worker resource and heartbeat data consumed by resource health aggregation.
  • ByteVeda/taskito#385: Previously implemented the dashboard operational health handlers that this change centralizes and re-exports.

Suggested labels: docs, tests

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately names the main change: standalone Node health and readiness helpers.
Linked Issues check ✅ Passed The PR delivers standalone checkHealth/checkReadiness helpers and exports them at the package root, matching #519.
Out of Scope Changes check ✅ Passed The code, route, test, and docs changes all support the health/readiness helper work and do not appear unrelated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/node-health-helpers

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdks/node/src/scaler/server.ts`:
- Line 43: Update the scaler request handler in server.ts to recognize the
`/readiness` route alongside `/health`, call the existing readiness check, and
return HTTP 503 when the scaler is degraded while preserving the current healthy
response behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe1d89a6-a2a1-411e-a661-dc097ae94753

📥 Commits

Reviewing files that changed from the base of the PR and between ba8086d and 31141c8.

📒 Files selected for processing (12)
  • docs/content/docs/node/guides/integrations/express.mdx
  • docs/content/docs/node/guides/integrations/fastify.mdx
  • docs/content/docs/node/guides/observability/monitoring.mdx
  • docs/content/docs/shared/guides/operations/deployment.mdx
  • sdks/node/src/contrib/rest.ts
  • sdks/node/src/dashboard/handlers/ops.ts
  • sdks/node/src/dashboard/server.ts
  • sdks/node/src/health.ts
  • sdks/node/src/index.ts
  • sdks/node/src/scaler/server.ts
  • sdks/node/test/integrations/rest.test.ts
  • sdks/node/test/observability/health.test.ts

Comment thread sdks/node/src/scaler/server.ts
@kartikeya-27
kartikeya-27 merged commit 46acc59 into master Jul 25, 2026
21 checks passed
@pratyush618
pratyush618 deleted the feat/node-health-helpers branch July 25, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node: standalone health/readiness helpers

2 participants