Zip async correctness fix#129122
Merged
alinpahontu2912 merged 3 commits intoJun 9, 2026
Merged
Conversation
…path ZipEndOfCentralDirectoryBlock.ReadBlockAsync called the synchronous Stream.ReadExactly when copying the archive comment after the EOCD header. This blocks the calling thread on the underlying stream and silently ignores the supplied CancellationToken. Switch to ReadExactlyAsync with ConfigureAwait(false), matching the rest of the async path. Adds a regression test using CallTrackingStream to verify the async open path never invokes the synchronous Stream.Read or ReadByte when reading an archive with a non-empty comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…p-async-correctness-fix
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes async ZIP reading correctness by ensuring the archive comment is read asynchronously (avoiding synchronous Stream.Read* calls) on the async code path, and adds a regression test to validate the behavior.
Changes:
- Switch
ZipEndOfCentralDirectoryBlock.ReadBlockAsyncto useReadExactlyAsync(..., cancellationToken)when reading the archive-level comment. - Add a unit test that asserts
ZipArchive.CreateAsync(...)+ZipArchive.Commentdoes not invoke synchronousStream.Read/Stream.ReadByteon the provided stream.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.Async.cs | Replaces a synchronous ReadExactly with await ReadExactlyAsync(..., cancellationToken) to keep the async path fully async. |
| src/libraries/System.IO.Compression/tests/ZipArchive/zip_ReadTests.cs | Adds a regression test using CallTrackingStream to ensure async ZIP open + comment retrieval doesn’t call sync read APIs. |
iremyux
approved these changes
Jun 8, 2026
rzikm
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix mix of sync/async reads when reading zip comment