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

YARP keeps buffering response returned as AsyncEnumerable even if AllowResponseBuffering is set to false #2616

Closed
saksham-simcorp opened this issue Sep 26, 2024 · 4 comments
Labels
needs-author-action An issue or pull request that requires more info or actions from the author. Type: Bug Something isn't working

Comments

@saksham-simcorp
Copy link

saksham-simcorp commented Sep 26, 2024

Describe the bug

I am currently having setup of microservices in dotnet where Dapr with YARP is configured on gateway. In one of the service I have a api endpoint which streams response of type AsyncEnumerable<string>. But when hitting api through gateway responses are not streamed and if keeps in pending state until completed.

To Reproduce

What steps can we follow to reproduce the issue?
When I try hitting endpoint of service directly I get expected results and can see chunks being logged in browser console as they are returned, but when request goes through gateway it keeps in pending status until it gets processed completely then only it gives response.
Also when I hit service directly I get response headers as Transfer Encoding "chunked", but when routing through gateway this doesn't happens. I also tried setting AllowResponseBuffering flag to false through app-setting configuration & also through appconfig.yaml in docker compose command to run dapr.

Further technical details

  • YARP (2.2.0)
  • Dapr (1.12.0)
@saksham-simcorp saksham-simcorp added the Type: Bug Something isn't working label Sep 26, 2024
@MihaZupan
Copy link
Member

YARP does not do any such buffering, it is likely the tool you're using to view the response (Browser?) is only rendering it once it has received all of it.

E.g. if you try reading the response with HttpClient, do you see it being delayed?

using var client = new HttpClient();
await using Stream stream = await client.GetStreamAsync("http://localhost:5000/yourApi");

byte[] buffer = new byte[1000];
int read;
while ((read = await stream.ReadAsync(buffer)) >= 0)
{
    Console.WriteLine(Encoding.UTF8.GetString(buffer.AsSpan(0, read)));
}

@MihaZupan MihaZupan added the needs-author-action An issue or pull request that requires more info or actions from the author. label Sep 26, 2024
@saksham-simcorp
Copy link
Author

saksham-simcorp commented Sep 27, 2024

Same issue is there while running from this HttpClient code which I am facing on browser with js client.
When I bypass gateway and access service directly it responds properly and I can see response chunks being printed on console.
Gateway has Dapr & Yarp configured for forwarding request and no additional middleware. Do you think it could be a issue with Dapr?

@MihaZupan
Copy link
Member

MihaZupan commented Sep 28, 2024

Can you please share your YARP configuration / create a minimal runnable repro?
YARP doesn't do any buffering so that's odd.

@adityamandaleeka
Copy link
Member

Closing since there hasn't been a response...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-author-action An issue or pull request that requires more info or actions from the author. Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants