Skip to content

Asynchronous ZipArchive stream methods still call synchronous methods of the underlying stream #107171

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

Closed
serggusak opened this issue Aug 30, 2024 · 4 comments
Assignees
Milestone

Comments

@serggusak
Copy link

Description

Asynchronous ZipArchive stream methods still call synchronous methods of the underlying stream:

using (var zip = new ZipArchive(/new WriteOnlyStreamWrapper(/httpContext.Response.Body/)/, ZipArchiveMode.Create))
await using (Stream strm = zip.CreateEntry("response").Open())
{
await strm.WriteAsync(bytes); // Synchronous operations are disallowed exception here
}

If I debug using my wrapper, I can see that Flush is called on the stream instead of FlushAsync

Reproduction Steps

Write some code that creates a ZipArchive for writing around a stream that supports only asynchronous operations, creates an entry, open it and write some data to the stream asynchronously.

Expected behavior

The data has been successfully written

Actual behavior

Get "Synchronous operations are disallowed" exception because the framework calls a synchronous method (Flush)

Regression?

No response

Known Workarounds

No response

Configuration

.Net 8, Windows, x64

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@ericstj ericstj added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Sep 4, 2024
@ericstj ericstj added this to the Future milestone Sep 4, 2024
@ericstj
Copy link
Member

ericstj commented Sep 4, 2024

Triage: not a regression - could be considered for the future with a proposed design change.

@carlossanlop
Copy link
Contributor

This should've been fixed with the introduction of the new async APIs: #114421

I added tests to confirm that no zip async APIs are calling stream sync APIs, and no zip sync APIs are calling stream async APIs.

@serggusak do you have a chance to test the new APIs?

@carlossanlop carlossanlop removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Apr 17, 2025
@carlossanlop carlossanlop self-assigned this Apr 17, 2025
@carlossanlop
Copy link
Contributor

This should be fixed now. If anyone finds problems, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants