Registry / devops / grpc-caller

grpc-caller

JSON →
library0.14.0jsnpmunverified

A Node.js gRPC client wrapper that promisifies unary and streaming calls, adds retry support, and automates metadata creation. Current stable version is 0.14.0. Built on top of @grpc/grpc-js (peer dependency ^1.2.5). Differs from vanilla gRPC client by providing async/await-friendly APIs, automatic plain-object-to-Metadata conversion via grpc-create-metadata, and optional retry logic for unary calls using async.retry semantics. Requires Node.js >=14.0.0.

npm install grpc-caller
INSTALL
IMPORT
SIG · GRPC-CALLER
G
grpc-caller
devopsjavascriptv0.14.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 (grpcCaller)
import grpcCaller from 'grpc-caller'
const { grpcCaller } = require('grpc-caller')
The module exports a single function as default, not a named export.
require('grpc-caller')
const caller = require('grpc-caller')
const caller = require('grpc-caller').default
In CommonJS, the default export is the entire module.exports, so .default is not needed.
TypeScript types
import caller from 'grpc-caller'
import * as caller from 'grpc-caller'
The library ships with types (see package.json 'types' field), but the default export is still a function, not a namespace.

Shows creating a gRPC client for a Greeter service and making a promisified unary call.

import caller from 'grpc-caller'; import path from 'path'; const PROTO_PATH = path.resolve(__dirname, './protos/helloworld.proto'); const client = caller('0.0.0.0:50051', PROTO_PATH, 'Greeter'); async function main() { const res = await client.sayHello({ name: 'Bob' }); console.log(res); } main().catch(console.error);
Debug
Known issues
breakingIn version 0.13.0, the API changed from exporting an object to a default function. Old `require('grpc-caller').caller` breaks.
fix
Update to `const caller = require('grpc-caller')`.
affects: <0.13.0
deprecatedThe `retry` option uses async.retry, which is deprecated in newer versions of async.
fix
Consider implementing custom retry logic if async is removed in future releases.
affects: >=0.14.0
gotchaAutomatic Metadata conversion only works for plain JavaScript objects; passing arrays or nested objects may cause unexpected behavior.
fix
Manually construct grpc.Metadata for complex metadata structures.
affects: >=0.14.0
gotchaStreaming response calls that omit the callback must destructure the returned object; forgetting this leads to undefined errors.
fix
Use `const { call, res } = client.writeStuff()` instead of just `client.writeStuff()`.
affects: >=0.14.0
deprecatedThe library still references `grpc` (the old package) in documentation but uses `@grpc/grpc-js` internally.
fix
Ensure you import `@grpc/grpc-js` explicitly if you need its classes.
affects: >=0.14.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc'
The package previously depended on `grpc`, but now uses `@grpc/grpc-js`. Old code may reference `grpc` directly.
fix
Install `@grpc/grpc-js` and replace `require('grpc')` with `require('@grpc/grpc-js')`.
TypeError: caller is not a function
Using named import `{ grpcCaller }` instead of default import.
fix
Change to `import caller from 'grpc-caller'` or `const caller = require('grpc-caller')`.
Cannot read property 'call' of undefined
Trying to destructure `call` and `res` from the result of a streaming call without using the returned object.
fix
Assign the result: `const result = client.writeStuff(); console.log(result.call, result.res);`
Error: 400 Bad Request - Metadata value must be a string or Buffer
Passing a non-object or complex nested object to metadata parameter.
fix
Pass a plain flat object like `{ key: 'value' }` or a proper grpc.Metadata instance.
Upgrade
Version history
0.14.0latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredRequired peer dependency; the actual gRPC implementation used for client connections.
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-caller — npm install grpc-caller · libregistry