Clean up logging (#286)

This commit is contained in:
Stephen Toub 2025-04-14 10:55:45 -04:00 • committed by GitHub
commit 312aede7d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Logging;
using ModelContextProtocol.Protocol.Messages;
using System;
using System.Diagnostics;
namespace ModelContextProtocol.Protocol.Transport;
@ -49,7 +49,6 @@ internal sealed class StdioClientSessionTransport : StreamClientSessionTransport
if (hasExited)
{
Logger.TransportNotConnected(EndpointName);
throw new McpTransportException("Transport is not connected", processException);
}
@ -59,7 +58,14 @@ internal sealed class StdioClientSessionTransport : StreamClientSessionTransport
/// <inheritdoc/>
protected override ValueTask CleanupAsync(CancellationToken cancellationToken)
{
StdioClientTransport.DisposeProcess(_process, processRunning: true, Logger, _options.ShutdownTimeout, EndpointName);
try
{
StdioClientTransport.DisposeProcess(_process, processRunning: true, _options.ShutdownTimeout, Name);
}
catch (Exception ex)
{
LogTransportShutdownFailed(Name, ex);
}
return base.CleanupAsync(cancellationToken);
}