Skip to content

Commit 6c794c4

Browse files
Fix Windows teardown flake in ClientE2ETests
Remove 'using var' from three ClientE2ETests that also call ForceStopAsync in their finally block. The double-disposal (using Dispose → DisposeAsync → ForceStopAsync, plus the explicit ForceStopAsync) races on Windows when the CLI process/pipes are mid-teardown, causing OperationCanceledException to bubble up and fail an otherwise-passing test. Matches the existing pattern in SessionFsE2ETests where ForceStopAsync is wrapped in try-catch to swallow teardown-only exceptions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 726a2e6 commit 6c794c4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

dotnet/test/E2E/ClientE2ETests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task Should_Force_Stop_Without_Cleanup()
6868
[Fact]
6969
public async Task Should_Get_Status_With_Version_And_Protocol_Info()
7070
{
71-
using var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
71+
var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
7272

7373
try
7474
{
@@ -83,14 +83,16 @@ public async Task Should_Get_Status_With_Version_And_Protocol_Info()
8383
}
8484
finally
8585
{
86-
await client.ForceStopAsync();
86+
try { await client.ForceStopAsync(); }
87+
catch (OperationCanceledException) { }
88+
catch (IOException) { }
8789
}
8890
}
8991

9092
[Fact]
9193
public async Task Should_Get_Auth_Status()
9294
{
93-
using var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
95+
var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
9496

9597
try
9698
{
@@ -108,14 +110,16 @@ public async Task Should_Get_Auth_Status()
108110
}
109111
finally
110112
{
111-
await client.ForceStopAsync();
113+
try { await client.ForceStopAsync(); }
114+
catch (OperationCanceledException) { }
115+
catch (IOException) { }
112116
}
113117
}
114118

115119
[Fact]
116120
public async Task Should_List_Models_When_Authenticated()
117121
{
118-
using var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
122+
var client = new CopilotClient(new CopilotClientOptions { UseStdio = true });
119123

120124
try
121125
{
@@ -144,7 +148,9 @@ public async Task Should_List_Models_When_Authenticated()
144148
}
145149
finally
146150
{
147-
await client.ForceStopAsync();
151+
try { await client.ForceStopAsync(); }
152+
catch (OperationCanceledException) { }
153+
catch (IOException) { }
148154
}
149155
}
150156

0 commit comments

Comments
 (0)