Skip to content

Chrome & Firefox Browser extension to aid gRPC-Web development using native gRPC-Web interceptors.

License

Notifications You must be signed in to change notification settings

alexrhogue/grpc-web-devtools

 
 

Repository files navigation

gRPC-Web Dev Tools Interceptor Edition

PRs Welcome

gRPC-Web Dev Tools Now supports dark mode.

gRPC-Web Interceptor Support

This fork of grpc-web-devtools adds support for native gRPC-Web interceptors.

SafetyCulture's previous version was incompatible with other gRPC-Web interceptors and broke them — which made debugging things like JWT authorization over gRPC-Web impossible.

This version fixes that by reimplementing the extension as a pair of native gRPC-Web interceptors. Now you can include the debug interceptors alongside the other gRPC-Web interceptors in your chain, and it "just works".

I also added a new icon to indicate when a stream has ended (vs. the call returning).

Currently, a unary gRPC-Web callback uses the same internal gRPC-Web code path as a streaming call (as opposed to a unary promise). As a result, the unary callback appears as a streaming call in the debug panel.

NOTE: This is a breaking change.

NEW Usage

const devInterceptors = window.__GRPCWEB_DEVTOOLS__ || (() => {});
const {
  devToolsUnaryInterceptor,
  devToolsStreamInterceptor,
} = devInterceptors();

const opts = {
  unaryInterceptors: [devToolsUnaryInterceptor],
  streamInterceptors: [devToolsStreamInterceptor],
};
const client = new EchoServiceClient('http://myapi.com', null, opts);

Installation

Chrome

Via the Chrome Web Store (recommended)

or

  1. build it with make build
  2. open the Extension Management page by navigating to chrome://extensions.
  3. enable Developer Mode by clicking the toggle switch next to "Developer mode".
  4. Click the LOAD UNPACKED button and select the extension ./build directory.

Firefox

Via Firefox Browser Add-Ons (recommended)

or

  1. build and package with make package
  2. enter about:debugging in the URL bar of Firefox
  3. click This Firefox > Load Temporary Add-on...
  4. select the grpc-web-devtools.zip extention file

Usage

const devInterceptors = window.__GRPCWEB_DEVTOOLS__ || (() => {});
const {
  devToolsUnaryInterceptor,
  devToolsStreamInterceptor,
} = devInterceptors();

const opts = {
  unaryInterceptors: [devToolsUnaryInterceptor],
  streamInterceptors: [devToolsStreamInterceptor],
};
const client = new EchoServiceClient('http://myapi.com', null, opts);

NOTE: Requires clients use grpc-web >= 1.2.1 Requires that your generated client(s) use protoc-gen-grpc-web >= 1.2.1 protoc-gen-grpc-web v1.2.1 is bundled

Example

The example uses docker-compose to start a simple gRPC server, JavaScript client and the Envoy proxy for gRPC-Web:

make example-up

Example will be running on http://localhost:8080

To stop the example:

make example-down

About

Chrome & Firefox Browser extension to aid gRPC-Web development using native gRPC-Web interceptors.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.5%
  • CSS 9.7%
  • HTML 3.1%
  • Go 1.9%
  • Makefile 1.4%
  • Dockerfile 0.4%