Registry / devops / grpc-health-check

grpc-health-check

JSON →
library2.1.0jsnpmunverified

Implementation of the gRPC Health Checking Protocol for gRPC-node. Provides both a client and a service implementation. Version 2.1.0 stable, actively maintained. Key differentiator: official package from the gRPC-node team, supports TypeScript out of the box, and allows dynamic status updates. Ships type definitions.

npm install grpc-health-check
INSTALL
IMPORT
SIG · GRPC-HEALTH-CHECK
G
grpc-health-check
devopsjavascriptv2.1.0
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.

HealthImplementation
import { HealthImplementation } from 'grpc-health-check'
const { HealthImplementation } = require('grpc-health-check')
ESM import only; package does not support CommonJS require
ServingStatusMap
import { ServingStatusMap } from 'grpc-health-check'
import ServingStatusMap from 'grpc-health-check'
Named import, not default. TypeScript type.
service
import { service } from 'grpc-health-check'
const service = require('grpc-health-check').service
ESM only; used to generate client stubs
servingStatus
import { servingStatus } from 'grpc-health-check'
import servingStatus from 'grpc-health-check'
Named import, not default.
protoPath
import { protoPath } from 'grpc-health-check'
Exported path to health.proto for CLI usage

Creates a gRPC server with health check service, adds health implementation with status map, and starts listening on port 50051.

import { HealthImplementation, ServingStatusMap } from 'grpc-health-check'; import * as grpc from '@grpc/grpc-js'; const server = new grpc.Server(); const statusMap: ServingStatusMap = { '': 'NOT_SERVING', 'MyService': 'SERVING', }; const healthImpl = new HealthImplementation(statusMap); healthImpl.addToServer(server); server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => { server.start(); console.log('Server with health check running on 0.0.0.0:50051'); });
Debug
Known issues
gotchaHas peer dependencies on @grpc/grpc-js and @grpc/proto-loader. Make sure they are installed.
fix
npm install @grpc/grpc-js @grpc/proto-loader
affects: >=1.0.0
gotchaThe import path 'grpc-health-check' is ESM only; requires 'type': 'module' in package.json or .mjs extension.
fix
Use .mjs extension or set 'type': 'module' in package.json
affects: >=2.0.0
gotchaServingStatusMap keys must be service names as strings. Empty string '' represents overall health.
fix
Ensure you include the empty string key for overall health status.
affects: *
deprecatedThe package 'grpc-health-check' is deprecated in favor of '@grpc/grpc-js' built-in health check? No, it's still active. This warning is a placeholder.
fix
Still maintained; no replacement.
affects: >=2.1.0
Errors
Common errors & fixes
Cannot find module 'grpc-health-check' or its corresponding type declarations.
Missing peer dependencies or incorrect import syntax.
fix
Install peer dependencies: npm install @grpc/grpc-js @grpc/proto-loader. Use ESM import.
TypeError: grpc.health.check is not a function
Incorrect usage: trying to call health check as a function instead of using the service.
fix
Import { service } and use it to create a client via grpc.makeGenericClientConstructor.
Error: 12 UNIMPLEMENTED: unknown service grpc.health.v1.Health
Server does not have the health implementation added.
fix
Call healthImpl.addToServer(server) after constructing the HealthImplementation.
Type '{}' is not assignable to parameter of type 'ServingStatusMap'
Empty object provided instead of a proper status map.
fix
Pass an object with at least the '' key, e.g., { '': 'SERVING' }.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency for gRPC functionality
@grpc/proto-loaderrequiredUsed for loading .proto files
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-health-check — npm install grpc-health-check · libregistry