Registry / devops / grpc-promise-client

grpc-promise-client

JSON →
library3.0.0jsnpmunverified

grpc-promise-client (v3.0.0) wraps @grpc/grpc-js clients to return Promises instead of callbacks, enabling async/await usage in Node.js. Ships TypeScript types. Released under Apache-2.0. Alternatives include grpc-promise and other promisify wrappers; this package focuses on minimal API surface and compatibility with @grpc/grpc-js v1.x. Maintenance is community-driven with infrequent releases.

npm install grpc-promise-client
INSTALL
IMPORT
SIG · GRPC-PROMISE-CLIEN
G
grpc-promise-client
devopsjavascriptv3.0.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.

grpcClientFactory
import { grpcClientFactory } from 'grpc-promise-client'
const grpcClientFactory = require('grpc-promise-client')
Package is ESM and exports named factory. Default import is not available.
GrpcClientFactory
import type { GrpcClientFactory } from 'grpc-promise-client'
import { GrpcClientFactory } from 'grpc-promise-client'
GrpcClientFactory is a type export, import with 'type' modifier in TypeScript.
GrpcClientFactoryConfig
import type { GrpcClientFactoryConfig } from 'grpc-promise-client'
Type for the configuration object passed to grpcClientFactory.

Shows how to create a promised-based gRPC client using the factory and call a unary RPC with async/await.

import { credentials } from "@grpc/grpc-js"; import { grpcClientFactory } from "grpc-promise-client"; import { BookServiceClient } from "./book_grpc_pb"; const createGrpcClient = grpcClientFactory({ defaultAddress: "localhost:50000", credentials: credentials.createInsecure(), }); async function main() { const bookService = createGrpcClient(BookServiceClient); const res = await bookService.getBook({ name: "Harry Potter" }); console.log(res); } main().catch(console.error);
Debug
Known issues
gotchaAll gRPC call types (unary, server streaming, client streaming, bidirectional) return promises. For streaming, the promise resolves with the stream object, not the data.
fix
For streaming calls, handle the stream manually after the promise resolves.
affects: >=3.0.0
deprecatedThe package only supports @grpc/grpc-js v1.14.2+. Older versions are not compatible.
fix
Upgrade @grpc/grpc-js to ^1.14.2.
affects: <3.0.0
breakingVersion 3.0.0 drops support for CommonJS; only ESM is supported.
fix
Use ESM imports (import/export) instead of require().
affects: >=3.0.0
gotchaThe factory requires protobuf message classes (not plain objects) for request and response types.
fix
Ensure the client constructor accepts message classes; use generated *_pb.js files.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: grpcClientFactory is not a function
Default import used instead of named import.
fix
import { grpcClientFactory } from 'grpc-promise-client';
Error: @grpc/grpc-js must be installed as a peer dependency
Missing or wrong version of @grpc/grpc-js.
fix
npm install @grpc/grpc-js@^1.14.2
TypeError: bookService.getBook is not a function
The client class does not have a matching method; maybe the proto definition differs.
fix
Verify the RPC method names in your .proto file and regenerated client.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredpeer dependency, provides the underlying gRPC client
google-protobufrequiredpeer dependency, used for protobuf message classes
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-promise-client — npm install grpc-promise-client · libregistry