Registry / devops / grpc-js-health-check

grpc-js-health-check

JSON →
library1.2.2jsnpmunverified

A drop-in replacement for grpc-health-check, implementing the gRPC Health Checking Protocol (defined in grpc/grpc-proto) using @grpc/grpc-js. Version 1.2.2 (latest) supports both Check and Watch methods, and is compatible with @grpc/grpc-js 1.9.x and @grpc/proto-loader 0.7.x. Lightweight and easy to integrate — just provide a status map and add the service to your gRPC server. This package is actively maintained and follows the same API as the original grpc-health-check package.

npm install grpc-js-health-check
INSTALL
IMPORT
SIG · GRPC-JS-HEALTH-CHE
G
grpc-js-health-check
devopsjavascriptv1.2.2
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.

Implementation
import { Implementation } from 'grpc-js-health-check'
const Implementation = require('grpc-js-health-check').Implementation;
Default export is not available; always use named import. CommonJS require() works as shown but ESM is preferred.
servingStatus
import { servingStatus } from 'grpc-js-health-check'
const { status } = require('grpc-js-health-check');
Note: The object is named 'servingStatus' (not 'status') to avoid collision with gRPC status codes.
service
import { service } from 'grpc-js-health-check'
This is the service definition object used for adding to the gRPC server. No common wrong pattern.

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

const grpc = require('@grpc/grpc-js'); const { servingStatus, Implementation, service } = require('grpc-js-health-check'); const statusMap = { '': servingStatus.SERVING, 'myService': servingStatus.NOT_SERVING, }; const healthImpl = new Implementation(statusMap); const server = new grpc.Server(); server.addService(service, healthImpl); server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => { server.start(); console.log('Health check server running on port 50051'); });
Debug
Known issues
breakingVersion 1.x uses @grpc/grpc-js 1.x. If you upgrade from a previous version that used grpc package (not @grpc/grpc-js), ensure you have migrated to @grpc/grpc-js.
fix
Replace imports from 'grpc' with '@grpc/grpc-js' and update server creation accordingly.
affects: >=1.0.0
deprecatedThe original grpc-health-check package is deprecated; grpc-js-health-check is its recommended replacement.
fix
Replace 'grpc-health-check' with 'grpc-js-health-check' in your package.json and imports.
affects: >=0.0.0
gotchaThe 'service' object must be added via server.addService, not passed as a regular handler.
fix
Use: server.addService(service, healthImpl);
affects: >=1.0.0
gotchaThe status map must include an empty string key for the default service health status.
fix
Ensure statusMap[''] is defined, e.g., '': servingStatus.SERVING
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Implementation is not a constructor
Using 'Implementation' incorrectly as a default import or mis-importing.
fix
Use named import: const { Implementation } = require('grpc-js-health-check');
Error: Cannot find module '@grpc/grpc-js'
@grpc/grpc-js is not installed.
fix
Run: npm install @grpc/grpc-js
TypeError: Cannot read properties of undefined (reading 'SERVING')
Misspelled 'servingStatus' or used wrong import.
fix
Import { servingStatus } correctly, then use servingStatus.SERVING
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
@grpc/grpc-jsoptionalRequired dependency for gRPC implementation; peer dependency that must be installed separately.
@grpc/proto-loaderoptionalUsed to load the health check proto definition; required at runtime.
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-js-health-check — npm install grpc-js-health-check · libregistry