{"id":48977,"library":"promisify-grpc-client","title":"promisify-grpc-client","description":"Utility to convert gRPC client methods generated by @grpc/grpc-js from callback-based to Promise-based, with full TypeScript type declaration support. Current version is 4.0.0-alpha.1, which is an alpha release. The library wraps each client method to return a Promise, preserving the original method signatures and types. It differentiates from generic promisification libraries by being specifically tailored to @grpc/grpc-js generated clients, ensuring correct handling of gRPC errors and metadata. Suitable for projects migrating from callbacks to async/await.","status":"active","version":"4.0.0-alpha.1","language":"javascript","source_language":"en","source_url":"https://github.com/cnwangjie/promisify-grpc-client","tags":["javascript","typescript"],"install":[{"cmd":"npm install promisify-grpc-client","lang":"bash","label":"npm"},{"cmd":"yarn add promisify-grpc-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add promisify-grpc-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: the gRPC client to be promisified must be generated by this package","package":"@grpc/grpc-js","optional":false},{"reason":"peer dependency: required for protobuf types used in gRPC calls","package":"google-protobuf","optional":false},{"reason":"peer dependency: TypeScript type definitions for google-protobuf","package":"@types/google-protobuf","optional":true}],"imports":[{"note":"The package is ESM-only since v4.0.0-alpha.1. Use default import.","wrong":"const promisifyGrpcClient = require('promisify-grpc-client');","symbol":"promisifyGrpcClient","correct":"import promisifyGrpcClient from 'promisify-grpc-client';"},{"note":"While the package exports a default, named import is also available. However, the default import is the intended usage.","wrong":"import promisifyGrpcClient from 'promisify-grpc-client';","symbol":"promisifyGrpcClient","correct":"import { promisifyGrpcClient } from 'promisify-grpc-client';"},{"note":"In TypeScript, use type-only import to avoid runtime value ambiguity. PromisifiedClient is a type.","wrong":"import { PromisifiedClient } from 'promisify-grpc-client';","symbol":"type PromisifiedClient","correct":"import type { PromisifiedClient } from 'promisify-grpc-client';"}],"quickstart":{"code":"import promisifyGrpcClient from 'promisify-grpc-client';\nimport { MyServiceClient } from './generated/my-service_grpc_pb';\n\nconst client = new MyServiceClient('localhost:50051', grpc.credentials.createInsecure());\n\nconst promisifiedClient = promisifyGrpcClient(client);\n\nasync function run() {\n  try {\n    const response = await promisifiedClient.myMethod({ name: 'world' });\n    console.log('Response:', response.getMessage());\n  } catch (error) {\n    console.error('gRPC error:', error);\n  }\n}\n\nrun();","lang":"typescript","description":"Demonstrates importing the default function, creating a gRPC client, promisifying it, and using async/await to call a method."},"warnings":[{"fix":"Use ES module import or downgrade to v3.x if CommonJS required.","message":"Package is ESM-only from v4.0.0-alpha.1. CommonJS require() will fail.","severity":"breaking","affected_versions":">=4.0.0-alpha.1"},{"fix":"Use at your own risk; pin to exact version and test thoroughly.","message":"Version 4.0.0-alpha.1 is an alpha release and may have breaking changes before stable.","severity":"deprecated","affected_versions":"4.0.0-alpha.1"},{"fix":"Ensure you are using @grpc/grpc-js and the generated client classes.","message":"The promisify function only works with clients generated by @grpc/grpc-js, not grpc (the deprecated package).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import type { PromisifiedClient } from 'promisify-grpc-client'; to avoid runtime import.","message":"TypeScript types may require explicit import of PromisifiedClient for complex scenarios.","severity":"gotcha","affected_versions":">=4.0.0-alpha.1"},{"fix":"Check the documentation for which methods are supported. Use a different pattern for streaming methods.","message":"Unary and response-streaming methods are supported; client-streaming and bidi-streaming methods are not promisified.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'4.0.0':31 'alpha':36 'alpha.1':32 'async/await':84 'base':17,21 'callback':16,82 'callback-bas':15 'client':4,9,42,68 'convert':7 'correct':70 'current':28 'declar':26 'differenti':56 'ensur':69 'error':74 'full':23 'generat':11,67 'generic':58 'grpc':3,8,73 'grpc/grpc-js':13,66 'handl':71 'javascript':85 'librari':39,60 'metadata':76 'method':10,43,51 'migrat':80 'origin':50 'preserv':48 'project':79 'promis':20,47 'promise-bas':19 'promisif':59 'promisifi':2 'promisify-grpc-cli':1 'releas':37 'return':45 'signatur':52 'specif':63 'suitabl':77 'support':27 'tailor':64 'type':25,54 'typescript':24,86 'util':5 'version':29 'wrap':40","created_at":"2026-06-07T16:59:25.680062+00:00","updated_at":"2026-06-07T16:59:25.680062+00:00","problems":[{"fix":"Set \"type\": \"module\" in package.json, or use .mjs extension, or downgrade to v3.x.","cause":"Using require() or running in a CommonJS environment without ESM support.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure the client is generated by @grpc/grpc-js and that you are using the correct service client.","cause":"The client does not have the expected method (maybe not generated by @grpc/grpc-js or incorrect client class).","error":"TypeError: client.myMethod is not a function"},{"fix":"Install google-protobuf: npm install google-protobuf","cause":"Missing peer dependency google-protobuf.","error":"Error: Cannot find module 'google-protobuf'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/cnwangjie/promisify-grpc-client#readme","github":"https://github.com/cnwangjie/promisify-grpc-client","docs":null,"changelog":null,"pypi":null,"npm":"promisify-grpc-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}