grpc / grpc/grpc-web

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

Open
#1,519 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
9.3k
Forks
801
Avg merge
1d 7h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the generated client stubs and unary interceptor wiring produced by the provided protoc command between grpc-web 1.5.0 and 2.0.2. Reproduce the issue using the GrpcLogInterceptor, AppModule registration, and FileStorageService setup shown here. Done means identifying whether the upgrade changed the required configuration and confirming that the interceptor runs for a unary call.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, grpc, javascript
Domain
api, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.