{"id":47999,"library":"grpc-client-egg","title":"egg-grpc-client","description":"An Egg.js plugin providing a gRPC client bridge for Node.js microservices. Version 0.1.3 is the current stable release; no known release cadence. It simplifies gRPC service invocation within Egg.js applications by auto-loading proto files, managing connections, and exposing promisified RPC calls via `this.app.grpcClient`. Differentiators: tight integration with Egg.js plugin system, TypeScript type support, and opinionated default loader config (e.g., keepCase, longs-as-String). Suitable for teams building Egg.js backend services with gRPC.","status":"active","version":"0.1.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install grpc-client-egg","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-client-egg","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-client-egg","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Egg.js application framework to load as plugin","package":"egg","optional":false},{"reason":"Core gRPC library for JavaScript","package":"grpc","optional":false}],"imports":[{"note":"Must use EggPlugin type and ESM export for Egg.js 3+","wrong":"const plugin = { grpcClient: { enable: true, package: 'grpc-client-egg' } }; module.exports = plugin","symbol":"grpcClient (plugin config)","correct":"import { EggPlugin } from 'egg'; const plugin: EggPlugin = { grpcClient: { enable: true, package: 'grpc-client-egg' } }; export default plugin"},{"note":"Access via app.grpcClient – correctly uses bracket notation for dynamic names","wrong":"const client = this.app.grpcClient['main'].greeter.Greeter","symbol":"this.app.grpcClient","correct":"const client = this.app.grpcClient[name].service[package][service]"},{"note":"Must use PowerPartial and ESM export for type safety in Egg.js 3+","wrong":"module.exports = { grpcClient: { clients: [{ name: 'main', protoPath: 'app/proto/main', host: '0.0.0.0', port: 50051 }] } }","symbol":"grpc client configuration","correct":"import { EggAppConfig, PowerPartial } from 'egg'; const config: PowerPartial<EggAppConfig> = { grpcClient: { clients: [{ name: 'main', protoPath: 'app/proto/main', host: '0.0.0.0', port: 50051 }] } }; export default config"}],"quickstart":{"code":"// 1. Install\n// npm i -S grpc-client-egg\n\n// 2. Plugin config (plugin.ts)\nimport { EggPlugin } from 'egg'\nconst plugin: EggPlugin = {\n  grpcClient: {\n    enable: true,\n    package: 'grpc-client-egg',\n  },\n}\nexport default plugin\n\n// 3. Application config (config.default.ts)\nimport { EggAppConfig, PowerPartial } from 'egg'\nexport default () => {\n  const config: PowerPartial<EggAppConfig> = {\n    grpcClient: {\n      clients: [\n        {\n          name: 'main',\n          protoPath: 'app/proto/main',\n          host: process.env.GRPC_HOST ?? '0.0.0.0',\n          port: Number(process.env.GRPC_PORT ?? 50051),\n        },\n      ],\n    },\n  }\n  return config\n}\n\n// 4. Service usage\nimport { Service } from 'egg'\ninterface GreeterService {\n  sayHello(params: { name: string }): Promise<{ message: string }>\n}\nexport default class Greeter extends Service {\n  readonly service: GreeterService = this.app.grpcClient.main.greeter.Greeter\n  public async sayHello(name: string) {\n    return this.service.sayHello({ name })\n  }\n}","lang":"typescript","description":"Shows complete setup: install, plugin enable, config with proto path, and using promisified client in a service."},"warnings":[{"fix":"Use absolute path or path.resolve(__dirname, 'proto') in config.","message":"Proto file path resolution: protoPath should be relative to app root or absolute; relative paths may break in production.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"npm install grpc@1.24.11 (last stable version of grpc).","message":"gRPC package compatibility: grpc-client-egg depends on the 'grpc' npm package (not @grpc/grpc-js). Ensure you install grpc version 1.x.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider migrating to a plugin that uses @grpc/grpc-js.","message":"The 'grpc' package is deprecated in favor of '@grpc/grpc-js' which is pure JS and actively maintained.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Use a proxy or manual load balancing logic.","message":"Load balancer: grpc-client-egg does not support load balancing out of the box; clients are single-host connections.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Restart the Egg.js application after proto changes.","message":"Proto file changes require restart: proto descriptors are loaded at startup; dynamic proto reload not supported.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.3':17 'applic':34 'auto':37 'auto-load':36 'backend':76 'bridg':12 'build':74 'cadenc':26 'call':47 'client':4,11 'config':64 'connect':42 'current':20 'default':62 'differenti':50 'e.g':65 'egg':2 'egg-grpc-client':1 'egg.js':6,33,54,75 'expos':44 'file':40 'grpc':3,10,29,79 'integr':52 'invoc':31 'javascript':80 'keepcas':66 'known':24 'load':38 'loader':63 'long':68 'longs-as-str':67 'manag':41 'microservic':15 'node.js':14 'opinion':61 'plugin':7,55 'promisifi':45 'proto':39 'provid':8 'releas':22,25 'rpc':46 'servic':30,77 'simplifi':28 'stabl':21 'string':70 'suitabl':71 'support':59 'system':56 'team':73 'this.app.grpcclient':49 'tight':51 'type':58 'typescript':57 'version':16 'via':48 'within':32","created_at":"2026-06-07T16:54:24.871438+00:00","updated_at":"2026-06-07T16:54:24.871438+00:00","problems":[{"fix":"Verify client name 'main' matches config, and that proto defines 'greeter.Greeter' service.","cause":"grpcClient service not initialized or invalid client name/service path","error":"TypeError: Cannot read property 'Greeter' of undefined"},{"fix":"Run: npm install grpc","cause":"Peer dependency 'grpc' not installed","error":"Error: Cannot find module 'grpc'"},{"fix":"Ensure protoPath is relative to app root or absolute, and the proto file exists.","cause":"protoPath config is incorrect or file missing","error":"Error: ENOENT: no such file or directory, open '/path/to/app/proto/main.proto'"},{"fix":"Check host and port in config; ensure gRPC server is running and accessible.","cause":"gRPC server host/port incorrect or server down","error":"Error: 14 UNAVAILABLE: failed to connect to all addresses"},{"fix":"Confirm plugin.ts has correct package name 'grpc-client-egg' and enable: true.","cause":"Plugin not enabled or package name wrong","error":"TypeError: this.app.grpcClient is undefined"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"grpc-client-egg","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"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}}