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

Intermittent error "Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead." #6

Open
scott-moxham opened this issue Jun 28, 2023 · 3 comments
Assignees

Comments

@scott-moxham
Copy link

I've tweaked your .Net6 example to zip a large collection of files instead of 2 urls (aprox 27,000 files, each 3KB in size).
It normally works however sometimes, I get the error message "Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead." This seems to happen particularly frequently when I use Postman to download the file instead of Edge.

This looks to be an issue with ZipArchive dispose and was reported here. The issue has been combined with general async support for ZipArchive here.

Is there any way around this, apart from setting Kestrel to allow synchronous operations?

@StephenCleary
Copy link
Contributor

The only other workaround I can think of is to use a producer/consumer stream (i.e., a buffering stream that supports simultaneous reads and writes) in-between the ZipArchive stream and the ASP.NET stream.

There's no type I'm aware of that does this, but I've seen it come up so many times over the years that I'll probably just sit down and write one.

@StephenCleary StephenCleary self-assigned this Jun 28, 2023
@scott-moxham
Copy link
Author

Thanks @StephenCleary
I appreciate the prompt response.
In my app, I've implemented some middleware to enable Synchronous IO for specific URIs as a workaround for now. Hopefully the async Zip support will get added to .Net and this will no longer be an issue.

@scott-moxham
Copy link
Author

Actually, it appears that PR#5 seems to fix the issue without needing to enable Synchronous IO in Kestrel.

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

2 participants