I recently upgraded grpc-web in my Angular project from 1.5.0 to 2.0.2. After the upgrade, I had to re-generate the client stubs from my .proto files using the following command:
protoc -I=. file_upload.proto \
--js_out=import_style=commonjs,binary:. \
--grpc-web_out=import_style=commonjs+dts,mode=grpcweb:.
After this change, my unary interceptor is no longer invoked. The interceptor itself compiles correctly, but its intercept method is never called.
Interceptor implementation (full code)
@Injectable()
export class GrpcLogInterceptor {
async intercept<
T extends { ... },
R extends { ... }
>(request: T, invoker: (arg0: T) => Promise<R>): Promise<R> {
const response = await invoker(request);
...
return response;
}
}
Registration in AppModule
providers: [
{ provide: GRPC_INTERCEPTORS, useClass: GrpcLogInterceptor, multi: true },
],
Injection and client setup (full code)
export class FileStorageService {
private fileUploadService: FileUploadGrpcEndpointClient;
constructor(
@Inject(GRPC_INTERCEPTORS) interceptors: any[],
) {
this.fileUploadService = new FileUploadGrpcEndpointClient(
environment.services.fileStorage.url,
{},
{ unaryInterceptors: interceptors },
);
}
}
This setup worked as expected with grpc-web 1.5.0, but after upgrading to 2.0.2, the interceptor is never executed.
Is there a breaking change in how unary interceptors are wired or invoked in newer versions of grpc-web, or is additional configuration required?
Any guidance would be appreciated.
I recently upgraded grpc-web in my Angular project from 1.5.0 to 2.0.2. After the upgrade, I had to re-generate the client stubs from my .proto files using the following command:
After this change, my unary interceptor is no longer invoked. The interceptor itself compiles correctly, but its intercept method is never called.
Interceptor implementation (full code)
Registration in AppModule
Injection and client setup (full code)
This setup worked as expected with grpc-web 1.5.0, but after upgrading to 2.0.2, the interceptor is never executed.
Is there a breaking change in how unary interceptors are wired or invoked in newer versions of grpc-web, or is additional configuration required?
Any guidance would be appreciated.