Registry / testing / grpc-client-promise-wrapper

grpc-client-promise-wrapper

JSON →
library1.0.5jsnpmunverified

A lightweight wrapper for @grpc/grpc-js that converts callback-based gRPC client methods to Promises, supporting async/await. Version 1.0.5 (latest). Stable but rarely updated. Key differentiator: minimal abstraction—promisifies all methods automatically without configuration. Smaller than alternatives like @grpc/grpc-js's own promisification or grpc-promise.

npm install grpc-client-promise-wrapper
INSTALL
IMPORT
SIG · GRPC-CLIENT-PROMIS
G
grpc-client-promise-wrapper
testingjavascriptv1.0.5
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 promiseWrapper from 'grpc-client-promise-wrapper'
const promiseWrapper = require('grpc-client-promise-wrapper')
Package exports a default function. TypeScript requires default import (esModuleInterop) or `import * as`.
promiseWrapper
import promiseWrapper from 'grpc-client-promise-wrapper'
const { promiseWrapper } = require('grpc-client-promise-wrapper')
Named import does not exist; the module only exports a single default function.
require
const promiseWrapper = require('grpc-client-promise-wrapper')
const { default: promiseWrapper } = require('grpc-client-promise-wrapper')
CommonJS require returns the default directly, no .default property.

Shows how to load a proto, create a gRPC client, wrap it with promiseWrapper, and call a method using async/await.

const grpc = require('@grpc/grpc-js'); const protoLoader = require('@grpc/proto-loader'); const promiseWrapper = require('grpc-client-promise-wrapper'); const path = require('path'); async function main() { const packageDefinition = protoLoader.loadSync(path.join(__dirname, './test.proto')); const testService = grpc.loadPackageDefinition(packageDefinition).test; const client = new testService.TestService('localhost:3001', grpc.credentials.createInsecure()); const wrappedClient = promiseWrapper(client); const response = await wrappedClient.getTestFn({ inputParam: 'hello' }); console.log('Response:', response); } main().catch(console.error);
Debug
Known issues
gotchaWrapping the client mutates the original client object—methods become async.
fix
Create and wrap a fresh client instance each time, or be aware of side effects.
affects: >=1.0.0
deprecatedThe package relies on @grpc/proto-loader, which may have breaking changes. No peer dependency declaration.
fix
Manually install @grpc/proto-loader and keep it updated.
affects: >=1.0.0
gotchaTypeScript types are not shipped; you may need to declare a module or write your own types.
fix
Add a declaration file: `declare module 'grpc-client-promise-wrapper'`.
affects: >=1.0.0
breakingThe wrapper does not handle streaming RPCs (e.g., server streaming). Only unary calls are promisified.
fix
Use native @grpc/grpc-js streaming API for streams.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: promiseWrapper is not a function
Using ES import with `import * as promiseWrapper` and then calling `promiseWrapper(client)`.
fix
Use `import promiseWrapper from 'grpc-client-promise-wrapper'` or `const promiseWrapper = require('grpc-client-promise-wrapper')`.
Cannot read property 'getTestFn' of undefined
Proto service name mismatch or missing module path.
fix
Ensure the proto file service name matches and the package definition is loaded correctly.
Error: No method found for /test.TestService/GetTestFn
The gRPC server does not implement the method or service definition mismatch.
fix
Verify the server implements the exact same proto definition and that the channel is connected.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency for gRPC client
Agent activity
11 hits · last 30 days
node
10
Resources
grpc-client-promise-wrapper — npm install grpc-client-promise-wrapper · libregistry