Skip to content

Commit 63b255f

Browse files
improve ConnectAsync_CancellationRequestedAfterConnect_ThrowsOperation test (#45201)
Co-authored-by: wfurt <tweinfurt@yahoo.com>
1 parent 4cfc831 commit 63b255f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Generic;
5+
using System.IO;
56
using System.Net.Test.Common;
67
using System.Threading;
78
using System.Threading.Tasks;
@@ -277,10 +278,18 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
277278
releaseServer.SetResult();
278279
clientSocket.Dispose();
279280
}
280-
}, server => server.AcceptConnectionAsync(async connection =>
281+
}, async server =>
281282
{
282-
await releaseServer.Task;
283-
}), new LoopbackServer.Options { WebSocketEndpoint = true });
283+
try
284+
{
285+
await server.AcceptConnectionAsync(async connection =>
286+
{
287+
await releaseServer.Task;
288+
});
289+
}
290+
// Ignore IO exception on server as there are race conditions when client is cancelling.
291+
catch (IOException) { }
292+
}, new LoopbackServer.Options { WebSocketEndpoint = true });
284293
}
285294
}
286295
}

0 commit comments

Comments
 (0)