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

FluidViewRenderer.RenderViewAsync writes to stream syncronously in some situations #647

Closed
AlexGirardDev opened this issue May 2, 2024 · 3 comments · Fixed by #667
Closed

Comments

@AlexGirardDev
Copy link
Contributor

Hey,

I have been running into an issue when trying to use RenderViewAsync to write to an HTTP Response Body output stream.

It seems like RenderViewAsync writes to the stream passed in Syncronously in some situations which causes issues with Kestral unless you set this flag

I have created some unit tests reproducing the bugs in this branch

I was also able to produce this bug in the MVC sample in this branch

Some things i have noticed with this bug:

  • It only happens when rendering values to nested views
    • IE a section rendered inside a _Layout file, although this does not happen with renderBody
    • It only happens when acutaly writing a value from the context, i can make a section very large and it will not do a sync write
  • This only seems to happen when writing string values greater than 128 (ie if my first name was 129 chars long)
  • Its related to the buffer size of the writer
    • If you have a buffer size of 1024 and you try and write a string that is 1025 chars long it will always force the error
  • While the bug happens is related to buffer size, you can hit thit bug while writing values lower than the buffer size.
    • I think that what probably happens here is that if you try and write a value and it forces you to write over the end of the buffer it will forec a sync write. But if your value size is bigger than the buffer this always happens
      -I think that the default buffer size in the ASP.NET is bigger than 1024 (probably 4096) because the value needs to be much larger to force this error every time there but it is still possible
@sebastienros
Copy link
Owner

Can you create a PR with the test that FAILS in your branch? thanks

@sebastienros
Copy link
Owner

Maybe related to #601

@AlexGirardDev
Copy link
Contributor Author

#648

sebastienros added a commit that referenced this issue May 29, 2024
sebastienros added a commit that referenced this issue May 29, 2024
sebastienros added a commit that referenced this issue May 29, 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

Successfully merging a pull request may close this issue.

2 participants