I'm trying to return a cached response through the interceptor, but I 
couldn't find a way to make an early return. When the call is cancelled in 
the interceptor, the callback function doesn't get run. I get neither the 
error nor the response. Ideally, I would like to return a cached response 
after the call is cancelled.

Here's the interceptor. I called the cancel method inside:

```js 
const StreamInterceptor = function () {};
StreamInterceptor.prototype.intercept = function (request, invoker) {
  const InterceptedStream = function (stream) {
    this.stream = stream;
  };
  InterceptedStream.prototype.on = function (eventType, callback) {
    this.stream.on(eventType, callback);
    return this;
  };
  const stream = invoker(request);
  stream.cancel();
  return new InterceptedStream(stream);
}; 
```

Here's the client and the method call. The call is unary.

```js 
const client = new ServiceClient('http://localhost:8080', null, {
  streamInterceptors: [new StreamInterceptor()],
});
client.hello(message, {}, (err, res) => {
  console.log(res);
});
```

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/2c9ebf3c-6b77-4c43-90ca-392189999c7en%40googlegroups.com.

Reply via email to