SafetyCulture / grpc-web-devtools

Chrome & Firefox Browser extension to aid gRPC-Web development
MIT License
402 stars 51 forks source link

gRPC-Web Developer Tools conflicts with unary interceptors introduced by grpc/grpc-web #80

Open bassbeaver opened 3 years ago

bassbeaver commented 3 years ago

I'v found that enabled gRPC-Web Developer Tools (by SafetyCulture) brokes up unary interceptors set up for grpc-web client. Interceptors are being not called when gRPC-Web Developer Tools are enabled.

Issue was found with next code:

const AuthInterceptor = function() {
    this.intercept = function(request, invoker) {
        request.getMetadata().Authorization = AuthService.GetAuthHeaderValue();

        return invoker(request);
    };
};

const options = {"unaryInterceptors": [new AuthInterceptor()]};
const APIClient = new APIPromiseClient(API_URL, null, options);

const enableDevTools = window.__GRPCWEB_DEVTOOLS__ || (() => {});
enableDevTools([
    APIClient,
]);

APIClient.me(new ProtobufEmpty(), {})
    .then(result => {
        ...
    })
    .catch(error => {
        console.error(error);    // <-- when gRPC-Web DevTools are enabled I receive error "no auth header" from my backend
    });
jrapoport commented 3 years ago

this will fix it https://github.com/SafetyCulture/grpc-web-devtools/pull/79

jrapoport commented 3 years ago

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

CyborgMaster commented 3 years ago

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.

jrapoport commented 3 years ago

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.

Whitelisted as in published as a Chrome extension? If so, happy to submit it if that will unblock you.

CyborgMaster commented 3 years ago

@jrapoport, sorry for the delayed response. Unfortunately that won't help us here. The IT org has chrome locked down so we can only install extensions from their whitelist, so even if you published it, I'd have to get it through the approval process, which is a bunch of red tape. I understand their concern, there is a fair bit of malware on the chrome extension store.

segfault16 commented 2 years ago

I spent a lot of time figuring out why my interceptors for handling errors don't work... Please look into merging that PR :)

infodusha commented 2 years ago

Can we label this? Look like "On approval" or smth

shaders commented 2 years ago

Is this repo still maintained? This issue is still valid and needs to be fixed.

nibres commented 1 year ago

Created this PR with several lines of code to fix this issue.

usertest123test commented 1 year ago

Facing similar issue. Please let me know if any fix or workaround for this ?