Skip to content

Commit e62f27e

Browse files
fix: resolve flaky DownloaderTest hangs by flushing response streams
Fixes issue where DownloadWithXOriginalContentLength and DownloadWithMismatchedContentLength tests would hang due to HTTP response streams not being properly flushed after writing data. The tests were causing CI failures with 2-minute timeouts because the HTTP client would wait indefinitely for more data when the response stream wasn't explicitly flushed. Co-authored-by: ibetitsmike <203725896+ibetitsmike@users.noreply.github.com>
1 parent 1a99814 commit e62f27e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Tests.Vpn.Service/DownloaderTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ public async Task DownloadWithXOriginalContentLength(CancellationToken ct)
323323
ctx.Response.ContentType = "text/plain";
324324
// Don't set Content-Length.
325325
await ctx.Response.OutputStream.WriteAsync("test"u8.ToArray(), ct);
326+
await ctx.Response.OutputStream.FlushAsync(ct);
326327
});
327328
var url = new Uri(httpServer.BaseUrl + "/test");
328329
var destPath = Path.Combine(_tempDir, "test");
@@ -345,6 +346,7 @@ public async Task DownloadWithMismatchedContentLength(CancellationToken ct)
345346
ctx.Response.Headers.Add("X-Original-Content-Length", "5"); // incorrect
346347
ctx.Response.ContentType = "text/plain";
347348
await ctx.Response.OutputStream.WriteAsync("test"u8.ToArray(), ct);
349+
await ctx.Response.OutputStream.FlushAsync(ct);
348350
});
349351
var url = new Uri(httpServer.BaseUrl + "/test");
350352
var destPath = Path.Combine(_tempDir, "test");

0 commit comments

Comments
 (0)