Registry / devops / grpc-server-register

grpc-server-register

JSON →
library1.0.4jsnpmunverified

A Node.js library for registering gRPC servers with etcd for service discovery. Version 1.0.4 is the latest release; it wraps the etcd3 and grpc packages to provide a simple registry/unregister API. Key differentiator: opinionated integration with etcd3 for service naming, supporting multiple etcd endpoints. The package uses callbacks and does not ship TypeScript definitions.

npm install grpc-server-register
INSTALL
IMPORT
SIG · GRPC-SERVER-REGIST
G
grpc-server-register
devopsjavascriptv1.0.4
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.

registry
const { registry } = require('grpc-server-register');
import { registry } from 'grpc-server-register';
Package is CJS-only, no ESM support.
unregistry
const { unregistry } = require('grpc-server-register');
import { unregistry } from 'grpc-server-register';
CJS-only export
default import
const register = require('grpc-server-register');
const register = require('grpc-server-register').default;
Exports an object with registry and unregistry functions; no default export.

Registers a gRPC server with etcd using the library, starts the server, and unregisters on shutdown.

const { registry, unregistry } = require('grpc-server-register'); const path = require('path'); const grpc = require('grpc'); const PROTO_PATH = path.join(__dirname, 'hw.proto'); const rpc_proto = grpc.load(PROTO_PATH).rpc; function sayHello(call, callback) { callback(null, { message: 'Hello from Node' }); } async function main() { await registry('etcd3_naming', 'hello_service', '0.0.0.0', 50051, 'localhost:2379', 10, 15); const server = new grpc.Server(); server.addService(rpc_proto.Greeter.service, { sayHello }); server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); server.start(); console.log('Server running on port 50051'); } process.on('SIGINT', () => unregistry()); main().catch(console.error);
Debug
Known issues
breakingetcd3 library is required as a dependency but not installed automatically
fix
Install the peer dependency: npm install etcd3 grpc
affects: >=1.0.0
gotchaThe registry function signature expects a long list of positional arguments (7 params) - easy to misorder
fix
Double-check parameter order: prefix, serviceName, ip, port, endpoints, ttl, timeout
affects: >=1.0.0
deprecatedThe grpc npm package is deprecated in favor of @grpc/grpc-js
fix
Migrate to @grpc/grpc-js for modern gRPC support; this library may not work with it.
affects: >=1.0.0
gotchaCalling registry() without awaiting can cause unhandled promise rejections if it throws
fix
Always use await or catch on the returned promise.
affects: >=1.0.0
gotchaThe unregistry function does not accept arguments and will unregister only the most recent registry call
fix
For multiple services, manage separate registry instances manually.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: register.registry is not a function
Incorrect import: using default import syntax for a CJS module
fix
Use const register = require('grpc-server-register'); then register.registry(...)
Error: connect ECONNREFUSED 127.0.0.1:2379
etcd server is not running or endpoints are misconfigured
fix
Ensure etcd is accessible at the provided endpoints; check network connectivity.
Cannot find module 'etcd3'
Peer dependency etcd3 is not installed
fix
Run npm install etcd3
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'service' of undefined
gRPC proto loading failed or service definition not found
fix
Verify PROTO_PATH points to valid .proto file and that the service is correctly defined.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
etcd3requiredClient library for etcd, used for service registration
grpcrequiredgRPC JavaScript library, required for server setup
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-server-register — npm install grpc-server-register · libregistry