Skip to content

Commit b7c8684

Browse files
committed
Address PR feedback.
1 parent e5f8bb6 commit b7c8684

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/ModelContextProtocol/Client/AutoDetectingClientSessionTransport.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ private async Task InitializeAsync(JsonRpcMessage message, CancellationToken can
7979
LogUsingStreamableHttp(_name);
8080
ActiveTransport = streamableHttpTransport;
8181
}
82-
finally
82+
catch
8383
{
84-
if (ActiveTransport is null)
85-
{
86-
await streamableHttpTransport.DisposeAsync().ConfigureAwait(false);
87-
}
84+
// If nothing threw inside the try block, we've either set streamableHttpTransport as the
85+
// ActiveTransport, or else we will have disposed it in the !IsSuccessStatusCode if statement.
86+
await streamableHttpTransport.DisposeAsync().ConfigureAwait(false);
87+
throw;
8888
}
8989
}
9090

src/ModelContextProtocol/Client/SseClientTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task<ITransport> ConnectAsync(CancellationToken cancellationToken =
6666
case HttpTransportMode.Sse:
6767
return await ConnectSseTransportAsync(cancellationToken).ConfigureAwait(false);
6868
default:
69-
throw new ArgumentException($"Unsupported transport mode: {_options.TransportMode}", nameof(_options.TransportMode));
69+
throw new InvalidOperationException($"Unsupported transport mode: {_options.TransportMode}");
7070
}
7171
}
7272

0 commit comments

Comments
 (0)