Registry / communication / grpc-web-rx

grpc-web-rx

JSON →
library0.6.14jsnpmunverified

gRPC-Web-Rx is a TypeScript library that integrates gRPC-Web with RxJS, providing a convenience `from` operator to wrap gRPC unary and server streaming calls as Observables. It supports automatic retries with exponential backoff and custom retry policies. Current stable version is 0.6.14, released on npm. This library is maintained by Wisetime. Key differentiators: it offers a simple RxJS-based abstraction over gRPC-Web, including a `retry` operator with `beforeRetry` hooks, and requires only `grpc-web` and `rxjs` as peer dependencies.

npm install grpc-web-rx
INSTALL
IMPORT
SIG · GRPC-WEB-RX
G
grpc-web-rx
communicationjavascriptv0.6.14
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.

from
import { from } from 'grpc-web-rx'
const from = require('grpc-web-rx').from
ESM import is recommended; CommonJS require works but is not the primary usage pattern.
retry
import { retry } from 'grpc-web-rx'
import { retry } from 'rxjs/operators'
This `retry` is specific to grpc-web-rx, not the RxJS `retry` operator.
withExponentialDelay
import { withExponentialDelay } from 'grpc-web-rx'
Helper function for creating delay functions used in retry policies.

Demonstrates creating a gRPC-Web client, using the from operator to make a unary call, and applying a retry policy with exponential delay.

import { from, retry, withExponentialDelay } from 'grpc-web-rx' import { CreateTodoRequest, TodoServiceClient } from './generated' // generated gRPC-Web code const client = new TodoServiceClient(process.env.GRPC_ENDPOINT ?? 'http://localhost:8080') const request = new CreateTodoRequest().setTitle('Buy milk') const policy = { shouldRetry: (error) => error.code === 7, // PERMISSION_DENIED maxRetries: 3, beforeRetry: withExponentialDelay(200)(() => console.log('Retrying...')) } from(() => client.createTodo(request)) .pipe(retry(policy)) .subscribe({ next: (response) => console.log('Created:', response.toObject()), error: (err) => console.error('Failed:', err), complete: () => console.log('Done') })
Debug
Known issues
gotchaOnly unary and server streaming RPCs are supported. Client streaming and bidirectional streaming are not yet supported by gRPC-Web itself, so grpc-web-rx cannot support them either.
fix
Use only unary or server streaming calls; check gRPC-Web status for updates.
affects: >=0.0.0
deprecatedThe `retry` operator imported from grpc-web-rx is different from RxJS's `retry` operator. Ensure you import from the correct package.
fix
Use `import { retry } from 'grpc-web-rx'` for grpc-web-rx retries, not from 'rxjs/operators'.
affects: >=0.0.0
breakingVersion 0.6.x may have breaking changes from 0.5.x. Check changelog for details.
fix
Review migration guide if upgrading from 0.5.x.
affects: >=0.6.0 <0.7.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc-web-rx'
Package not installed
fix
Run `npm install grpc-web-rx`
TypeError: grpc_web_rx__WEBPACK_IMPORTED_MODULE_0__.from is not a function
Incorrect import (CommonJS vs ESM)
fix
Use ES module syntax: `import { from } from 'grpc-web-rx'`
Uncaught Error: gRPC-Web is not supported
Browser does not support gRPC-Web transport
fix
Ensure you are using a modern browser and the server supports gRPC-Web (e.g., Envoy proxy).
Upgrade
Version history
0.6.14latest on npm
Audit
Dependencies
grpc-webrequiredPeer dependency: gRPC-Web client library used for making calls
rxjsrequiredPeer dependency: RxJS Observables are used as the return type
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
grpc-web-rx — npm install grpc-web-rx · libregistry