Registry / devops / grpc-promisify

grpc-promisify

JSON →
library0.1.0jsnpmunverified

A lightweight utility to convert gRPC client callbacks into Promises for Node.js. Current stable version is 0.1.0, released as an early alpha with no recent updates. It wraps grpc-js (or grpc) client methods to return promises instead of using callbacks. Differentiates from @grpc/proto-loader and grpc-js-native by offering a simple promisify-only function, but lacks TypeScript support, streaming handling, and active maintenance.

npm install grpc-promisify
INSTALL
IMPORT
SIG · GRPC-PROMISIFY
G
grpc-promisify
devopsjavascriptv0.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.

default
import promisify from 'grpc-promisify';
import { promisify } from 'grpc-promisify';
Only a default export; named import will fail.
default
const promisify = require('grpc-promisify');
const { promisify } = require('grpc-promisify');
CommonJS default import, not destructured.
default
import promisify from 'grpc-promisify';
const promisify = require('grpc-promisify').default;
In ESM, default export is directly available; no .default needed.

Shows how to promisify a gRPC client and call a unary RPC with promises.

const PROTO_PATH = __dirname + '/hello.proto'; const promisify = require('grpc-promisify'); const grpc = require('@grpc/grpc-js'); const hello_proto = grpc.load(PROTO_PATH).helloworld; function main() { const client = new hello_proto.Greeter('localhost:50051', grpc.credentials.createInsecure()); const user = 'hello'; promisify(client); client.sayHello({name: user}) .then(res => console.log(res.message)) .catch(err => console.error(err)); } main();
Debug
Known issues
deprecatedThe package has not been updated since 2018 and is considered abandoned.
fix
Use @grpc/grpc-js with built-in promise support or a maintained promisify library.
affects: >=0.0.0
gotchaThe promisify function mutates the client object by overriding methods; do not reuse the client for callback-based calls.
fix
Promisify a fresh client instance each time or keep a separate copy.
affects: >=0.0.0
gotchaStreaming RPCs (server streaming, client streaming, bidirectional) are not supported; only unary calls.
fix
Use @grpc/grpc-js built-in promise support for streaming or manage streams manually.
affects: >=0.0.0
gotchaDoes not handle errors thrown by the client constructor; errors in promisify may surface as unresolved promises.
fix
Wrap the call in try-catch or use .catch on the promised call.
affects: >=0.0.0
breakingIncompatible with @grpc/proto-loader v0.7+; only works with older grpc.load() style.
fix
Use @grpc/grpc-js and @grpc/proto-loader without promisify, or manually wrap methods.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: promisify is not a function
Wrong import style: using named import 'const { promisify } = require(...)' instead of default import.
fix
const promisify = require('grpc-promisify');
TypeError: client.sayHello(...).then is not a function
The client was not promisified before calling the method, or the method is not a unary RPC (streaming).
fix
Ensure call to promisify(client) before invoking any RPCs, and only use for unary calls.
Error: Cannot find module 'grpc'
Missing peer dependency grpc or @grpc/grpc-js.
fix
npm install @grpc/grpc-js or npm install grpc
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
grpcrequiredPeer dependency: requires @grpc/grpc-js or grpc package for gRPC client
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-promisify — npm install grpc-promisify · libregistry