Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cancelled on client" error in gRPC Client streaming RPC scenario #264

Closed
PrasadJayakumar opened this issue Mar 7, 2024 · 3 comments
Closed

Comments

@PrasadJayakumar
Copy link

Followed the steps detailed in https://httpyac.github.io/guide/request.html?#client-streaming-rpc

But, getting "Cancelled on client" error in gRPC Client streaming RPC scenario. Am I missing something?

Thank you for sharing the helpful tool.

GRPC /BasicService/CalculateAverage
{
  "value": 10
}

{{@streaming
  async function writeStream(){
    await sleep(1000);
    await $requestClient.send({
      value: 20,
    });
    await sleep(1000);
    await $requestClient.send({
      value: 30
    });
  }
  exports.waitPromise = writeStream();
}}
syntax = "proto3";

package grpc_basics;

service BasicService { 
 // Client streaming RPC: CalculateAverage
 rpc CalculateAverage (stream DataPoint) returns (AverageResponse);
}

message DataPoint {
  double value = 1;
}

message AverageResponse {
  double average = 1; 
}

Code behind the service is provided below.

  calculateAverage(call, callback) {
    // Simulating client streaming by calculating the average of received data points
    let totalSum = 0;
    let count = 0;

    call.on("data", (dataPoint) => {
      console.log("data", dataPoint);
      totalSum += dataPoint.value;
      count++;
    });

    call.on("end", () => {
      const average = count > 0 ? totalSum / count : 0;
      const response = { average: average };
      console.log("end", response);
      callback(null, response);
    });
  }
@tcinagaki
Copy link

Hello.
Same problem for me.
Maybe the reason is that if the StreamingScript terminates while the server is processing, the cancel method is executed.
(If the Sleep in the StreamingScript is made longer, the Response is returned normally, but it requires more Sleep than necessary.)
It would be great if an option could be implemented to not execute the cancel method even if it is available.

This problem does not occur in version 6.8.1

[6.8.2] (2023-10-23)
use grpc Stream cancel method if available

I like this great tool. Thank you.

@PrasadJayakumar
Copy link
Author

Hello. Same problem for me. Maybe the reason is that if the StreamingScript terminates while the server is processing, the cancel method is executed. (If the Sleep in the StreamingScript is made longer, the Response is returned normally, but it requires more Sleep than necessary.) It would be great if an option could be implemented to not execute the cancel method even if it is available.

This problem does not occur in version 6.8.1

[6.8.2] (2023-10-23) use grpc Stream cancel method if available

I like this great tool. Thank you.

Thank You.

Yes, Version 6.8.1 is working well.

@AnWeber
Copy link
Owner

AnWeber commented Mar 15, 2024

I would just like to briefly point out that v6.8.1 has a memory leak in the streams. You may need to restart the extension host or the entire IDE from time to time if you notice it in the performance.
Unfortunately when the streaming went through successfully I decided to call the cancel method instead of the .end(). Almost right. I have fixed it and will be delivered with next release. Tested with ClientStreaming on Postman Echo, but should be identical to your use case. Unfortunately I don't use grpc anymore.

@AnWeber AnWeber closed this as completed Mar 15, 2024
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

No branches or pull requests

3 participants