Registry / testing / nice-grpc-server-health

nice-grpc-server-health

JSON →
library2.0.19jsnpmunverified

Implementation of the gRPC Health Checking Protocol (defined by grpc-health-probing) for nice-grpc servers. Version 2.0.x is stable, actively maintained, with a simple API to register a health service and set service status. It integrates tightly with nice-grpc and uses the native gRPC health check proto. Compared to alternatives like grpc-js-health-check, it provides a typed, async-friendly interface for nice-grpc users.

npm install nice-grpc-server-health
INSTALL
IMPORT
SIG · NICE-GRPC-SERVER-H
N
nice-grpc-server-health
testingjavascriptv2.0.19
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ServerHealthDefinition
import { ServerHealthDefinition } from 'nice-grpc-server-health'
const { ServerHealthDefinition } = require('nice-grpc-server-health')
ESM-only package; use import syntax. TypeScript types are included.
HealthService
import { HealthService } from 'nice-grpc-server-health'
import { HealthService } from 'nice-grpc'
HealthService is re-exported from nice-grpc-server-health for convenience.
createHealthService
import { createHealthService } from 'nice-grpc-server-health'
import createHealthService from 'nice-grpc-server-health'
createHealthService is a named export, not the default.

Creates a gRPC health service and registers it on a nice-grpc server.

import { createServer } from 'nice-grpc'; import { createHealthService, ServerHealthDefinition } from 'nice-grpc-server-health'; import { health } from 'nice-grpc-server-health/generated/health'; const server = createServer(); server.addService(health.ServerHealthDefinition, createHealthService({ status: { '': health.HealthCheckResponse_ServingStatus.SERVING } })); server.listen('0.0.0.0:50051'); console.log('Server running on port 50051');
Debug
Known issues
breakingv2.0 changed the import path for generated proto types.
fix
Import from 'nice-grpc-server-health/generated/health' instead of 'nice-grpc-server-health/proto'
affects: >=2.0.0 <2.0.0
deprecatedThe `serverHealth` function from v1 is deprecated.
fix
Use `createHealthService` with `ServerHealthDefinition` instead.
affects: <2.0.0
gotchaThe health service must be registered before any other services to properly pass health checks.
fix
Register the health service as one of the first services on the server.
affects: >=1.0.0
gotchaSetting a service status to NOT_SERVING or UNKNOWN may cause load balancers to route traffic away; ensure proper transitions.
fix
Use `SERVING` for healthy services, `NOT_SERVING` only for intentional unavailability.
affects: >=1.0.0
breakingRemoved support for grpc-js in v2; requires nice-grpc v2+.
fix
Upgrade to nice-grpc v2 and use this package accordingly.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: healthService is not a function
Used deprecated `serverHealth()` from v1 instead of `createHealthService()` in v2.
fix
Replace `serverHealth()` with `createHealthService()` and pass options object.
Cannot find module 'nice-grpc-server-health/generated/health'
Outdated import path from package version before 2.0.
fix
Update to v2 and use the correct path: 'nice-grpc-server-health/generated/health'.
Error: The health service must be registered before other services
Attempted to register health service after other services, violating order requirement.
fix
Register health service first using `server.addService(ServerHealthDefinition, healthImpl)` before any other service.
Upgrade
Version history
2.0.19latest on npm
Audit
Dependencies
nice-grpcrequiredRequired to create and register the gRPC server and health service.
Agent activity
4 hits · last 30 days
node
4
Resources
nice-grpc-server-health — npm install nice-grpc-server-health · libregistry