feat(node): standalone health and readiness helpers - #545
Conversation
Probes usable without a dashboard; the dashboard and scaler now call them.
Adds health/readiness/resources to the Express and Fastify route table.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Node SDK adds standalone ChangesHealth probe implementation
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
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (12)
docs/content/docs/node/guides/integrations/express.mdxdocs/content/docs/node/guides/integrations/fastify.mdxdocs/content/docs/node/guides/observability/monitoring.mdxdocs/content/docs/shared/guides/operations/deployment.mdxsdks/node/src/contrib/rest.tssdks/node/src/dashboard/handlers/ops.tssdks/node/src/dashboard/server.tssdks/node/src/health.tssdks/node/src/index.tssdks/node/src/scaler/server.tssdks/node/test/integrations/rest.test.tssdks/node/test/observability/health.test.ts
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.tsholds them standalone:
checkHealth()→{ status: "ok" }— liveness, never touches storage.checkReadiness(queue)→{ status: "ready" | "degraded", checks }overstorage, workers, and worker resources. Never throws: a failing dependency is
reported as
"error: <message>"inchecksand degrades the status, so aprobe endpoint can always answer.
resourceStatus(queue)— per-resource health aggregated across every liveworker'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 thepackage 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
/healthand/readiness, the KEDA scaler server's/health(previously an inline literal), and the Express/Fastify REST table,which gains
health,readiness, andresourcesroutes under the same routenames the other SDK shells use. Readiness answers
503when degraded soorchestrators drain the instance.
dashboard/handlers/ops.tskeeps only thescaler 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, 1new REST probe-route test).
pnpm typecheck,pnpm lint, docs lint + typecheck clean.Summary by CodeRabbit
/health,/readiness, and/resourcesoperational endpoints across REST, dashboard, scaler, Express, and Fastify integrations.