Registry / search / grpc-web-error-details-bin

grpc-web-error-details-bin

JSON →
library1.1.2jsnpmunverified

Utility function for deserializing `grpc-status-details-bin` metadata on grpc-web to access richer gRPC error details (protobuf messages) in browser clients. Current stable version is 1.1.2. Release cadence is low; the library is stable and rarely updated. Key differentiator: unlike the official grpc-web library which only supports standard error model, this library provides `statusFromError` to extract structured error details (e.g., BadRequest, RetryInfo) comparable to server-side gRPC libraries. ESM-only; requires `google-protobuf` and `grpc-web` as peer dependencies. Ships TypeScript type definitions.

npm install grpc-web-error-details-bin
INSTALL
IMPORT
SIG · GRPC-WEB-ERROR-DET
G
grpc-web-error-details-bin
searchjavascriptv1.1.2
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.

statusFromError
import { statusFromError } from 'grpc-web-error-details'
const { statusFromError } = require('grpc-web-error-details')
ESM-only package; CommonJS require will fail. Use import.
BadRequest
import { BadRequest } from 'grpc-web-error-details'
import BadRequest from 'grpc-web-error-details/BadRequest'
BadRequest is a named export, not a default export or subpath export.
all error detail classes
import * as errorDetails from 'grpc-web-error-details'
const errorDetails = require('grpc-web-error-details')
ESM-only; use import star for convenient access to all detail types.

Demonstrates using statusFromError to extract structured error details (e.g., BadRequest field violations) from a gRPC-web error with metadata.

import { statusFromError, BadRequest, RetryInfo } from 'grpc-web-error-details'; import { GrpcWebClientBase } from 'grpc-web'; async function example() { const client = new GrpcWebClientBase({}); // Assume rpcCall returns a promise that may reject with error const fakeError = { code: 3, message: 'Invalid argument', metadata: new Map([['grpc-status-details-bin', 'CgVpbnZhbGQSGgoLRmllbGRWaW9sYXRpb24SCwoJZmllbGQxID0gJ3gn']]), }; const [status, details] = statusFromError(fakeError); if (status && details) { console.log('Status code:', status.getCode()); console.log('Status message:', status.getMessage()); for (const detail of details) { if (detail instanceof BadRequest) { for (const violation of detail.getFieldViolationsList()) { console.log(`Field: ${violation.getField()}, Description: ${violation.getDescription()}`); } } if (detail instanceof RetryInfo) { console.log('Retry after:', detail.getRetryDelay().getSeconds(), 'seconds'); } } } else { console.log('Not a valid gRPC error'); } } example();
Debug
Known issues
breakingLibrary is ESM-only since v1.0.0. CommonJS require() will throw at runtime.
fix
Use ES module import syntax (import { ... } from 'grpc-web-error-details').
affects: >=1.0.0
gotchaThe function returns [null, null] if the error does not contain valid grpc-status-details-bin metadata. Always check for null before accessing details.
fix
Use the pattern: const [status, details] = statusFromError(err); if (status && details) { ... }
affects: >=0.0.0
deprecatedThe metadata key is 'grpc-status-details-bin' (with 'status'), not 'grpc-web-details-bin' as the README mentions in its Motivation section (likely a typo).
fix
Ensure the metadata key in your gRPC-web response is 'grpc-status-details-bin'. The library uses the correct key internally.
affects: >=0.0.0
gotchaTypeScript users must install @types/google-protobuf separately if not using a bundler that provides types.
fix
Install peer dependencies: npm install google-protobuf @types/google-protobuf grpc-web
affects: >=1.0.0
breakingVersion 1.0.0 renamed from 'grpc-web-error-details' (initial) – no prior releases; breaking if you relied on internal module structure.
fix
Update imports to use the documented named exports. There is no legacy API.
affects: =1.0.0
Errors
Common errors & fixes
require() of ES Module /path/to/node_modules/grpc-web-error-details/index.js from /path/to/app.js not supported.
The package is ESM-only, but the consumer uses CommonJS require.
fix
Convert your file to ES module (use import syntax) or change the extension to .mjs.
TypeError: statusFromError is not a function
Importing the default export instead of named export.
fix
Use: import { statusFromError } from 'grpc-web-error-details';
Module not found: Can't resolve 'google-protobuf'
Peer dependency 'google-protobuf' is not installed.
fix
Run: npm install google-protobuf
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
google-protobufrequiredPeer dependency for protobuf message deserialization
grpc-webrequiredPeer dependency – the error object comes from grpc-web calls
Agent activity
37 hits · last 30 days
node
32
Amazon
1
Resources
grpc-web-error-details-bin — npm install grpc-web-error-details-bin · libregistry