grpc-web
grpc-web copied to clipboard
Asynchronous intercept method of StreamInterceptor
Is it possible to implement promise- or callback- based intercept
method of StreamInterceptor
like the UnaryInterceptor
? For example:
class StreamAuthInterceptor<REQ, RESP> implements StreamInterceptor<REQ, RESP> {
async intercept(
r: Request<REQ, RESP>,
invoker: (r: Request<REQ, RESP>) => ClientReadableStream<RESP>
): Promise<ClientReadableStream<RESP>> {
r.getMetadata()['authorization'] = await getAuth();
return invoker(r);
}
}
did you find a solution to this? Having the same issue trying to await for a jwt token refresh...
guess this is a duplicate of https://github.com/grpc/grpc-web/issues/988
@alienvspredator @dhax any solutions? running into the same use case also with doing JWT token refresh in the interceptor
@kurnal-volt no, I am only using an unaryInterceptor with the promise based client. Doesn't look like there was any progress regarding an async streamInterceptor.
@dhax could you show me what an example for a promise based unaryInterceptor is? also is there a promise based streamInterceptor?
@kurnal-volt have a look at the tests, e.g.: https://github.com/grpc/grpc-web/blob/master/packages/grpc-web/test/tsc-tests/client04.ts