Skip to content

Commit 6930bf1

Browse files
committed
Wrap the transport.close in a try-catch
1 parent f54b86f commit 6930bf1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/transports/streamableHttp.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,21 @@ export class StreamableHttpRunner extends TransportRunnerBase {
138138
});
139139
failedPings = 0;
140140
} catch (err) {
141-
this.logger.warning({
142-
id: LogId.streamableHttpTransportKeepAliveFailure,
143-
context: "streamableHttpTransport",
144-
message: `Error sending ping (attempt #${failedPings + 1}): ${err instanceof Error ? err.message : String(err)}`,
145-
});
146-
147-
if (++failedPings > 3) {
148-
clearInterval(keepAliveLoop);
149-
await transport.close();
141+
try {
142+
failedPings++;
143+
this.logger.warning({
144+
id: LogId.streamableHttpTransportKeepAliveFailure,
145+
context: "streamableHttpTransport",
146+
message: `Error sending ping (attempt #${failedPings}): ${err instanceof Error ? err.message : String(err)}`,
147+
});
148+
149+
if (failedPings > 3) {
150+
clearInterval(keepAliveLoop);
151+
await transport.close();
152+
}
153+
} catch {
154+
// Ignore the error of the transport close as there's nothing else
155+
// we can do at this point.
150156
}
151157
}
152158
}, 30_000);

0 commit comments

Comments
 (0)