Skip to content

Support unary interceptors in callback-style clients (rpcCall)#1532

Open
ganesh-tn wants to merge 4 commits into
grpc:masterfrom
ganesh-tn:Support-unary-interceptors-in-callback-style-clients-(rpcCall)
Open

Support unary interceptors in callback-style clients (rpcCall)#1532
ganesh-tn wants to merge 4 commits into
grpc:masterfrom
ganesh-tn:Support-unary-interceptors-in-callback-style-clients-(rpcCall)

Conversation

@ganesh-tn

@ganesh-tn ganesh-tn commented May 5, 2026

Copy link
Copy Markdown
Member

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

@Vuhag123

Vuhag123 commented May 14, 2026

Copy link
Copy Markdown
Collaborator

reverify

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #1519 where unary interceptors registered via unaryInterceptors were silently ignored on callback-style clients (those generated with import_style=commonjs+dts,mode=grpcweb, which call rpcCall). Before this PR, rpcCall only ran the streamInterceptors_ pipeline. The PR adds a new branch in rpcCall that, when the method is unary and at least one unary interceptor is configured, drives the request through the same unaryInterceptors_ chain used by thenableCall/unaryCall and bridges the Promise-based result back to the existing (error, response) callback contract via a proxy stream that queues listeners/cancellation until the interceptor chain produces the real underlying stream.

Changes:

  • Add a unary-interceptor branch to rpcCall that builds a Promise-returning initialInvoker (mirroring thenableCall) and runs it through runInterceptors_(..., unaryInterceptors_).
  • Introduce an inline proxyStream object so rpcCall can synchronously return a ClientUnaryCallImpl that supports on/removeListener/cancel even though the real stream is only created asynchronously by the interceptor chain.
  • Translate the resolved UnaryResponse (or rejection) back into the callback signature (error, responseMessage).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Comment thread javascript/net/grpc/web/grpcwebclientbase.js
Comment thread javascript/net/grpc/web/grpcwebclientbase.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants