grpc / grpc/grpc-web

Unary interceptors conflicts with gRPC-Web Developer Tools

Open
#1,012 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
802
Avg merge
1d 7h
Merged PRs (30d)
5

Description

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:

```JS
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
});
```

Also, this bug was posted to gRPC-web Developers Tools repo: https://github.com/SafetyCulture/grpc-web-devtools/issues/80
and I think it it rather looks like their job to fix this issue on their side. But I want to warn people here about such compatibleness (so that they do not waste time guessing why their UnaryInterceptors not working).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.