grpc-web-devtools icon indicating copy to clipboard operation
grpc-web-devtools copied to clipboard

Use grpc-web interceptors

Open jrapoport opened this issue 4 years ago • 9 comments

since they are interceptors they can now be chained properly as well. updated examples and docs. I also took the opportunity to update the dependencies and make a few minor tweaks like an stop icon for an EOF status.

usage is:

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

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

jrapoport avatar Dec 13 '20 08:12 jrapoport

We operate in a corporate environment so all of our chrome extensions have to be whitelisted. Therefore we aren't able to manually install the fork from @jrapoport. Anything we can do to get this fixed merged as soon as possible would be wonderful as we just currently cannot use gRPC-Web Developer Tools. Let me know if there is any way we can help.

CyborgMaster avatar Feb 04 '21 00:02 CyborgMaster

Be aware this piece will break when trying to destructure if __GRPCWEB_DEVTOOLS__ is not there as this piece (() => {}); will return undefined.

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

iCovarrubias avatar Feb 25 '21 23:02 iCovarrubias

Be aware this piece will break when trying to destructure if __GRPCWEB_DEVTOOLS__ is not there as this piece (() => {}); will return undefined.

fixed the example to recover gracefully if you run it without installing the tools.

jrapoport avatar Feb 26 '21 01:02 jrapoport

Hey @rogchap ,

Do you guys plan to merge this one? gRPC interceptors are a very clever solutions to many problems. On the other hand, gRPC-web devtools saves our lives every day. Right now we had to disable it because we need interceptors.

Is there any way we can help here?

ickata avatar Mar 16 '21 11:03 ickata

Hi, Can someone share the status of this MR? We use grpc-web-devtools at our company, but unfortunately it does not work well with gRPC interceptors.

FeNoMeNa avatar Mar 16 '21 11:03 FeNoMeNa

merged this change into my fork's master and updated the readme to reflect the change. I'm dropping a link here for anyone that finds this and wants to use native gRPC-Web interceptors: https://github.com/jrapoport/grpc-web-devtools

cc: @ickata @FeNoMeNa @iCovarrubias

jrapoport avatar Mar 16 '21 12:03 jrapoport

@jrapoport that's great, however I still think that your fix must become part of the official extension...

ickata avatar Mar 16 '21 12:03 ickata

Considering it’s (nearly) a complete re-write i guess depends on your pov. i broke the fork history and bumped to 2.0 for that reason.

jrapoport avatar Mar 16 '21 13:03 jrapoport

any updates?

shaders avatar Oct 04 '22 10:10 shaders