Registry /
observability / nice-grpc-client-middleware-devtools
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
devtoolsClientMiddleware
✓ import { devtoolsClientMiddleware } from 'nice-grpc-client-middleware-devtools';
✗ const { devtoolsClientMiddleware } = require('nice-grpc-client-middleware-devtools');
The `nice-grpc` ecosystem is primarily ESM-first and TypeScript-centric. While CommonJS might technically work with transpilation, direct `require` is not the idiomatic approach.
devtoolsUnaryLoggingMiddleware
✓ import { devtoolsUnaryLoggingMiddleware } from 'nice-grpc-client-middleware-devtools';
Use this specific middleware if you only want to log unary (request-response) gRPC calls to devtools, excluding streaming calls.
devtoolsStreamLoggingMiddleware
✓ import { devtoolsStreamLoggingMiddleware } from 'nice-grpc-client-middleware-devtools';
Use this specific middleware if you only want to log streaming gRPC calls to devtools, excluding unary calls.
This quickstart demonstrates how to integrate `devtoolsClientMiddleware` into a `nice-grpc-web` client, enabling automatic logging of gRPC-Web requests and responses to the `grpc-web-devtools` browser extension for debugging.
import { createClientFactory, createChannel, ClientError, Status } from 'nice-grpc-web';
import { devtoolsClientMiddleware } from 'nice-grpc-client-middleware-devtools';
import { type ExampleServiceDefinition, ExampleServiceDefinition } from './compiled_proto/example';
// Imagine your compiled Protobuf types look like this (e.g., from ts-proto)
interface ExampleServiceDefinition {
readonly methodName: string;
readonly requestType: any;
readonly responseType: any;
// ... other protobuf definitions
}
// 1. Define your gRPC service (usually compiled from .proto)
// ExampleServiceDefinition would come from your proto compilation output
// 2. Create a gRPC-Web channel pointing to your proxy/server
const channel = createChannel('http://localhost:8080');
// 3. Create a client factory and apply the devtools middleware
const clientFactory = createClientFactory()
.use(devtoolsClientMiddleware);
// 4. Create your gRPC client instance
const client = clientFactory.create(
ExampleServiceDefinition,
channel,
);
// 5. Make a gRPC call (this will now be logged in grpc-web-devtools)
async function callService() {
try {
console.log('Making a gRPC call...');
const response = await client.exampleMethod({ name: 'World' }, {
metadata: { 'x-request-id': '123' },
// Additional call options can be passed here
});
console.log('gRPC response:', response);
} catch (error: unknown) {
if (error instanceof ClientError) {
console.error(`gRPC Error: ${error.code} - ${error.details}`);
} else {
console.error('Unknown error:', error);
}
}
}
callService();
// A minimal example for ExampleServiceDefinition if not using ts-proto directly:
export const ExampleServiceDefinition = {
methodName: 'ExampleService',
requestType: {}, // Define your request type structure
responseType: {}, // Define your response type structure
// Typically, this comes from compiled .proto files
methods: {
exampleMethod: {},
}
} as unknown as ExampleServiceDefinition;
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use CommonJS `require()` syntax in an ESM-only or ESM-configured project.
fixUse ESM `import` statements: `import { devtoolsClientMiddleware } from 'nice-grpc-client-middleware-devtools';` TypeError: Cannot read properties of undefined (reading 'use')
Likely attempting to call `.use()` on something other than a `ClientFactory` or an incorrectly initialized factory.
fixEnsure you correctly import `createClientFactory` from `nice-grpc-web` and call `createClientFactory()` before chaining `.use()` calls: `const clientFactory = createClientFactory().use(middleware);`
gRPC-Web calls not appearing in browser's Network tab or grpc-web-devtools extension.
The `grpc-web-devtools` browser extension is not installed, not enabled, or the middleware is not correctly applied to the client factory. Also, ensure your gRPC-Web proxy (e.g., Envoy) is correctly configured.
fixVerify the `grpc-web-devtools` extension is installed and enabled. Double-check that `devtoolsClientMiddleware` is applied to your `createClientFactory()` instance. Ensure your browser is indeed making gRPC-Web requests (often visible as POST requests to `/Service/Method` with `Content-Type: application/grpc-web+proto` or `application/grpc-web-text`).
Audit
Dependencies
nice-grpc-webrequiredThis middleware is specifically designed to work with gRPC-Web clients and the `grpc-web-devtools` browser extension.
nice-grpcrequiredWhile primarily for web, `nice-grpc` is the foundational library for the ecosystem. The middleware expects a `nice-grpc` compatible client factory.
nice-grpc-commonrequiredProvides common types and utilities shared across the `nice-grpc` ecosystem.