From 03e9b87e43bb7e99201d41781b7a32fe0cfcc307 Mon Sep 17 00:00:00 2001 From: Eduard Dumitru Date: Tue, 24 Mar 2026 11:52:24 +0100 Subject: [PATCH] Fix net461 test runner hanging after all tests pass HttpListener.Stop() does not reliably unblock pending GetContextAsync() on .NET Framework 4.6.1, causing the xUnit test process to never exit. Use Abort()+Close() to force-close the request queue and add a timeout safety net. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Helpers/HttpSysWebSocketsListener.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/UiPath.CoreIpc.Tests/Helpers/HttpSysWebSocketsListener.cs b/src/UiPath.CoreIpc.Tests/Helpers/HttpSysWebSocketsListener.cs index 257e9a8b..d7552e67 100644 --- a/src/UiPath.CoreIpc.Tests/Helpers/HttpSysWebSocketsListener.cs +++ b/src/UiPath.CoreIpc.Tests/Helpers/HttpSysWebSocketsListener.cs @@ -54,19 +54,17 @@ public async Task Accept(CancellationToken ct) public async ValueTask DisposeAsync() { _cts.Cancel(); - _httpListener.Stop(); + _httpListener.Abort(); // Closes the request queue; unblocks pending GetContextAsync() + _httpListener.Close(); // Full resource cleanup try { - await _processingContexts; + // Safety net: on .NET Framework, GetContextAsync() may not respond to Abort()/Close(). + await Task.WhenAny(_processingContexts, Task.Delay(TimeSpan.FromSeconds(5))); } - catch (ObjectDisposedException) + catch { - // ignore - } - catch (OperationCanceledException ex) when (ex.CancellationToken == _cts.Token) - { - // ignore + // Swallow ObjectDisposedException / OperationCanceledException from the listener shutdown. } } } \ No newline at end of file