Registry / devops / grpc-reflection-js

grpc-reflection-js

JSON →
library0.3.0jsnpmunverified

A JavaScript library for querying gRPC server reflection protocol, allowing dynamic discovery of gRPC services and protobuf definitions at runtime. Version 0.3.0 is the latest stable release, with moderate release cadence. It simplifies interaction with gRPC servers that implement the reflection protocol by providing methods to list services, retrieve file descriptors by symbol or filename. Unlike alternatives like protobuf.js, it focuses solely on reflection, using the @grpc/grpc-js package for gRPC communication. The library ships TypeScript types for enhanced developer experience.

npm install grpc-reflection-js
INSTALL
IMPORT
SIG · GRPC-REFLECTION-JS
G
grpc-reflection-js
devopsjavascriptv0.3.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.

Client
import { Client } from 'grpc-reflection-js';
const Client = require('grpc-reflection-js').Client;
ESM and TypeScript: named export. CommonJS: destructure require.
grpc
import * as grpc from '@grpc/grpc-js';
const grpc = require('grpc');
Use @grpc/grpc-js, not the deprecated grpc package. ESM or CJS.
default import
import grpcReflection from 'grpc-reflection-js';
const grpcReflection = require('grpc-reflection-js');
Exists as default export for convenience, but named Client is typical.

Initialize a reflection client and list all gRPC services exposed by the server.

import { Client } from 'grpc-reflection-js'; import * as grpc from '@grpc/grpc-js'; const serverAddress = 'localhost:50051'; const client = new Client(serverAddress, grpc.credentials.createInsecure()); async function listServices() { try { const services = await client.listServices(); console.log('Services:', services); } catch (err) { console.error('Error:', err.message); } } listServices();
Debug
Known issues
breakingRequires @grpc/grpc-js v1.0+, not the older 'grpc' package.
fix
npm install @grpc/grpc-js@^1.0.0
affects: >=0.3.0
deprecatedThe API uses callbacks in older examples; current version returns Promises.
fix
Use async/await or .then() instead of callbacks.
affects: >=0.2.0
gotchaServer must implement gRPC reflection protocol v1alpha; otherwise listServices returns empty.
fix
Verify server supports reflection by checking its gRPC reflection service.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc'
Missing peer dependency @grpc/grpc-js or using deprecated 'grpc' package
fix
npm install @grpc/grpc-js
TypeError: grpc.credentials.createInsecure is not a function
Using the deprecated 'grpc' package instead of @grpc/grpc-js
fix
Import from '@grpc/grpc-js' and use appropriate credential methods
Error: 12 UNIMPLEMENTED: Method not found
Server does not support reflection or incorrect address
fix
Ensure the server implements grpc.reflection.v1alpha.ServerReflection service
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency for gRPC channel and credentials
Agent activity
4 hits · last 30 days
node
4
Resources
grpc-reflection-js — npm install grpc-reflection-js · libregistry