Registry /
testing / grpc-client-promise-wrapper
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);
Errors
Common errors & fixes
TypeError: promiseWrapper is not a function
Using ES import with `import * as promiseWrapper` and then calling `promiseWrapper(client)`.
fixUse `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.
fixEnsure 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.
fixVerify the server implements the exact same proto definition and that the channel is connected.
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency for gRPC client