Skip to content

Unary interceptor is not invoked after upgrading grpc-web from 1.5.0 to 2.0.2 #1519

@evgenii-petukhov

Description

@evgenii-petukhov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions