Add a timeout to the NuGet package downloads of the tests - #1308
Merged
Conversation
HttpClient.Timeout does not cover reading an unbuffered response stream, so a stalled connection made GetNuGetReferences hang forever. The result is shared by all the tests through the NuGetPackagesCache Lazy<Task>, so every test waiting on it hung too, and neither the retry loop nor HttpRetryMessageHandler could recover as they only react to exceptions and 5xx responses. Download the package to a buffer under a CancellationTokenSource timeout before opening the ZipArchive, and treat OperationCanceledException and TimeoutException as transient so the existing retry loop takes over.
This was referenced Aug 20, 2026
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.173
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#552
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.173
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#538
Closed
Closed
Closed
Closed
This was referenced Aug 27, 2026
Open
Bump Meziantou.Analyzer from 3.0.139 to 3.0.189
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#556
Open
Open
Bump Meziantou.Analyzer from 3.0.139 to 3.0.189
Analogy-LogViewer/Analogy.AspNetCore.LogProvider#542
Open
Open
Open
Open
Open
Open
Open
Open
Open
Bump Meziantou.Analyzer from 3.0.103 to 3.0.190
Analogy-LogViewer/Analogy.LogViewer.OpenTelemetry#99
Open
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.
GetNuGetReferencesintests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.csdownloaded the reference packages withGetStreamAsyncand read the resulting stream through aZipArchive.HttpClient.Timeoutdoes not cover reading an unbuffered response stream, and neitherDownloadPackageWithRetriesnorHttpRetryMessageHandlercould recover from a stalled read: they only react to exceptions and 5xx responses. A stalled connection therefore hung the download forever, and because the result is shared through theNuGetPackagesCacheLazy<Task<string[]>>, every test waiting on it hung too.This happened on CI in this run: the
build_and_test (Meziantou.Analyzer.Test.roslyn5.6)job ran 3629 tests successfully, thenRemoveEmptyStatementAnalyzerTests.ForStatement(a 0.6s test) was still running after 13 minutes and the hang dump policy killed the run with exit code 7.Changes
CancellationTokenSourcetimeout covering both the request and the stream read, and only then handed to theZipArchive. As the archive is opened over a buffer, the per-entry extraction can no longer stall on the network either.IsTransientExceptionnow also matchesOperationCanceledExceptionandTimeoutException, so the timeout feeds the existing retry loop instead of propagating. There is no outer cancellation token in this path, so this cannot swallow a legitimate cancellation.Testing
The local NuGet reference cache was moved aside so that the download path actually ran during the test runs.
dotnet test tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.roslyn5.9.csproj: 3663 passed, 0 failed, with a cold cache.dotnet test tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.roslyn4.8.csproj: 3533 passed, 0 failed.dotnet run --project src/DocumentationGenerator: exit code 0, no markdown change.