Registry / ai-ml / grpc-js-reflection-client

grpc-js-reflection-client

JSON →
library1.4.0jsnpmunverified

Client library for gRPC reflection API that dynamically loads protobuf service definitions from a running gRPC server without requiring local .proto files. Current stable version is 1.4.0. Released as needed. Enables runtime discovery of gRPC services and methods, generating client stubs on the fly. Differentiates from static protobuf compilation by eliminating the need to distribute proto files and allowing interaction with services whose schemas evolve independently. Supports ESM and CJS, ships TypeScript definitions. Requires @grpc/grpc-js as a peer dependency.

npm install grpc-js-reflection-client
INSTALL
IMPORT
SIG · GRPC-JS-REFLECTION
G
grpc-js-reflection-client
ai-mljavascriptv1.4.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.

createReflectionClient
import { createReflectionClient } from 'grpc-js-reflection-client'
const createReflectionClient = require('grpc-js-reflection-client')
Package is ESM-first; CommonJS require() works but type definitions may not resolve correctly.
loadFromReflection
import { loadFromReflection } from 'grpc-js-reflection-client'
const loadFromReflection = require('grpc-js-reflection-client').loadFromReflection
Named export; avoid using .default.
ReflectionClient
import { ReflectionClient } from 'grpc-js-reflection-client'
import ReflectionClient from 'grpc-js-reflection-client'
Export is named, not default.

Connects to a gRPC server running on localhost:50051, uses reflection to load the Greeter service, then calls SayHello with name 'world'.

import { createReflectionClient, loadFromReflection } from 'grpc-js-reflection-client'; import { GrpcClient } from '@grpc/grpc-js'; async function main() { const client = new GrpcClient('localhost:50051', GrpcClient.credentials.createInsecure()); const reflectionClient = createReflectionClient(client); const proto = await loadFromReflection(reflectionClient, 'helloworld.Greeter'); const greeter = new proto.Greeter('localhost:50051', GrpcClient.credentials.createInsecure(), {}); const response = await new Promise((resolve, reject) => { greeter.SayHello({ name: 'world' }, (err, res) => { if (err) reject(err); else resolve(res); }); }); console.log(response.message); client.close(); } main().catch(console.error);
Debug
Known issues
breakingPeer dependency @grpc/grpc-js must be version ^1.14.3. Using older versions may cause runtime errors due to incompatible types.
fix
Install @grpc/grpc-js@^1.14.3 alongside this package.
affects: <1.14.3
gotchaThe reflection API must be enabled on the target gRPC server, and the server must support the reflection protocol version used by this client.
fix
Ensure server implements gRPC reflection (e.g., grpc.reflection.v1alpha.ServerReflection).
affects: >=1.0.0
deprecatedUsing require() may cause TypeScript issues as package is ESM-first.
fix
Use import syntax in an ESM context.
affects: >=1.4.0
gotchaService names must include the full package path (e.g., 'mypackage.MyService'). Omitting package may fail to load.
fix
Always provide fully qualified service name (e.g., 'helloworld.Greeter').
affects: >=1.0.0
gotchaDynamic client generation may not support streaming calls correctly in all cases.
fix
Test streaming RPCs thoroughly; consider using a typed client if issues arise.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Unable to load service: ... not found in reflection response
Service name does not match exactly (case-sensitive) or package prefix missing.
fix
Provide full qualified service name, e.g. 'mypackage.MyService'.
TypeError: Cannot read properties of undefined (reading 'Greeter')
Service not loaded correctly; typo in service name or reflection not enabled on server.
fix
Verify service name and that server supports reflection.
Error: 12 UNIMPLEMENTED: grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo is not implemented
Server does not have reflection service enabled.
fix
Enable reflection on the gRPC server (e.g., use reflection.Register(grpcServer) with @grpc/proto-loader).
Module not found: Can't resolve 'grpc-js-reflection-client' in '/path/to/project'
Package not installed or missing from package.json.
fix
Run npm install grpc-js-reflection-client.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredpeer dependency required for gRPC client implementation
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
2
Resources
grpc-js-reflection-client — npm install grpc-js-reflection-client · libregistry