diff --git a/src/UiPath.CoreIpc/Helpers/Helpers.cs b/src/UiPath.CoreIpc/Helpers/Helpers.cs index abe5e0eb..9b81247c 100644 --- a/src/UiPath.CoreIpc/Helpers/Helpers.cs +++ b/src/UiPath.CoreIpc/Helpers/Helpers.cs @@ -60,7 +60,7 @@ internal static void LogException(this ILogger? logger, Exception ex, object tag if (logger is not null) { - logger.LogError(ex, message); + logger.LogError(message); return; } diff --git a/src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeServerTransport.cs b/src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeServerTransport.cs index 56661b57..63b8bb26 100644 --- a/src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeServerTransport.cs +++ b/src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeServerTransport.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using System.IO.Pipes; +using System.Runtime.InteropServices; using System.Security.Principal; namespace UiPath.Ipc.Transport.NamedPipe; @@ -79,16 +80,30 @@ ValueTask IAsyncDisposable.DisposeAsync() #endif } + private static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + async ValueTask IServerConnectionSlot.AwaitConnection(CancellationToken ct) { + if (IsWindows) + { + await Stream.WaitForConnectionAsync(ct); + return Stream; + } + // on Linux WaitForConnectionAsync has to be cancelled with Dispose using (ct.Register(StartDisposal)) { - await Stream.WaitForConnectionAsync(ct); + try + { + await Stream.WaitForConnectionAsync(); + } + catch (ObjectDisposedException) + { + } return Stream; } - void StartDisposal() => (this as IAsyncDisposable).DisposeAsync().AsTask().TraceError(); // We trace the error even we don't expect Dispose/DisposeAsync to ever throw. + void StartDisposal() => (this as IAsyncDisposable).DisposeAsync().AsTask().TraceError(); // We trace the error even though we don't expect Dispose/DisposeAsync to ever throw. } } }