Support unary interceptors in callback-style clients (rpcCall)#1532
Support unary interceptors in callback-style clients (rpcCall)#1532ganesh-tn wants to merge 4 commits into
Conversation
|
reverify |
There was a problem hiding this comment.
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
rpcCallthat builds a Promise-returninginitialInvoker(mirroringthenableCall) and runs it throughrunInterceptors_(..., unaryInterceptors_). - Introduce an inline
proxyStreamobject sorpcCallcan synchronously return aClientUnaryCallImplthat supportson/removeListener/canceleven 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.
#1519 Unary interceptor is not invoked after upgrading grpc-web from 1.5.0 to 2.0.2