Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/UiPath.CoreIpc/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 17 additions & 2 deletions src/UiPath.CoreIpc/Transport/NamedPipe/NamedPipeServerTransport.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System.IO.Pipes;
using System.Runtime.InteropServices;
using System.Security.Principal;

namespace UiPath.Ipc.Transport.NamedPipe;
Expand Down Expand Up @@ -79,16 +80,30 @@ ValueTask IAsyncDisposable.DisposeAsync()
#endif
}

private static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

async ValueTask<Stream> 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.
}
}
}