Registry / devops / grpc-promise

grpc-promise

JSON →
library1.4.0jsnpmunverified

A lightweight utility (v1.4.0) that promisifies all gRPC call types (unary, client/server stream, bidirectional stream) for Node.js, providing a unified Promise-based interface over the native callback/event-based gRPC API. It abstracts away the differences between simple and streaming RPCs, allowing developers to use async/await consistently. Last updated in 2019, it works with the original `grpc` package (not `@grpc/grpc-js`) and is in maintenance mode. Key differentiator: eliminates boilerplate for streaming calls by converting them to promise patterns, though newer alternatives like `@grpc/grpc-js` native promises may be preferred.

npm install grpc-promise
INSTALL
IMPORT
SIG · GRPC-PROMISE
G
grpc-promise
devopsjavascriptv1.4.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.

default import
const grpcPromise = require('grpc-promise');
import grpcPromise from 'grpc-promise';
This package is CommonJS-only (no ESM support). Must use require().
promisifyAll
const grpcPromise = require('grpc-promise'); grpcPromise.promisifyAll(protoDescriptor);
grpcPromise.promisifyAll(protoDescriptor.test);
Pass the full proto descriptor, not the service object. It modifies all service methods.
makeUnaryRequest
grpcPromise.makeUnaryRequest(client, 'TestSimpleSimple', request, metadata, options);
client.TestSimpleSimple(request, metadata, options).then(...);
Promisified method is attached to the client instance, but the original callback-style method is overwritten. Call the original name now returns a promise.

Promisifies a gRPC client so unary calls return promises, enabling async/await.

const grpc = require('grpc'); const protoLoader = require('@grpc/proto-loader'); const grpcPromise = require('grpc-promise'); const packageDefinition = protoLoader.loadSync('test.proto', { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }); const protoDescriptor = grpc.loadPackageDefinition(packageDefinition); const client = new protoDescriptor.test.Test('localhost:50051', grpc.credentials.createInsecure()); grpcPromise.promisifyAll(protoDescriptor); async function main() { const response = await client.TestSimpleSimple({ id: 1 }); console.log('Response:', response); } main().catch(console.error);
Debug
Known issues
deprecatedPackage depends on the deprecated `grpc` npm package (not `@grpc/grpc-js`). `grpc` is no longer maintained and may have security vulnerabilities.
fix
Migrate to `@grpc/grpc-js` which has built-in promise support, or use a fork like `grpc-promise-js` if available.
affects: >=1.0.0
breakingpromisifyAll modifies the proto descriptor globally, affecting all services. Can cause unexpected side effects if used with multiple clients.
fix
Call promisifyAll only once per proto descriptor, or use promisify on individual methods with grpcPromise.makeUnaryRequest etc.
affects: >=1.0.0 <2.0.0
gotchaFor streaming calls, the promise resolves with an EventEmitter or stream object, not the response data directly. This differs from unary calls.
fix
Attach event listeners (e.g., 'data', 'end') on the returned stream object for server and bidirectional streams.
affects: >=1.0.0
breakingMetadata and call options are passed as additional arguments after the request object, but the signature varies between unary and streaming methods.
fix
Consult the API documentation for the correct argument order for each call type.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: grpcPromise.promisifyAll is not a function
Incorrect import: using ES6 import syntax on CommonJS module.
fix
Use const grpcPromise = require('grpc-promise');
Error: Cannot read property 'TestSimpleSimple' of undefined
promisifyAll called before loading the proto descriptor, or passed wrong object.
fix
Ensure protoDescriptor is loaded and pass it to promisifyAll: grpcPromise.promisifyAll(protoDescriptor);
UnhandledPromiseRejectionWarning: Error: 12 UNIMPLEMENTED: Method not found
Server does not implement the RPC method, or service name mismatch.
fix
Check proto file and server implementation for correct method spelling and service registration.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
grpcrequiredPeer dependency – this library promisifies methods from the original `grpc` npm package, not `@grpc/grpc-js`.
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-promise — npm install grpc-promise · libregistry