refactor(mcp) Disable stdio server sink draining on close

This commit is contained in:
Christian Tzolov 2024-12-30 09:23:42 +01:00
commit dfa7435ad8

View file

@ -248,12 +248,14 @@ public class StdioServerTransport implements McpTransport {
return Mono.fromRunnable(() -> {
isClosing = true;
logger.debug("Initiating graceful shutdown");
}).then(Mono.defer(() -> {
// First complete the sinks to stop processing
inboundSink.tryEmitComplete();
outboundSink.tryEmitComplete();
return Mono.delay(Duration.ofMillis(200));
})).then(Mono.fromRunnable(() -> {
})
// .then(Mono.defer(() -> {
// // First complete the sinks to stop processing
// inboundSink.tryEmitComplete();
// outboundSink.tryEmitComplete();
// return Mono.delay(Duration.ofMillis(100));
// }))
.then(Mono.fromRunnable(() -> {
try {
// Dispose schedulers first
inboundScheduler.dispose();
@ -287,7 +289,9 @@ public class StdioServerTransport implements McpTransport {
catch (Exception e) {
logger.error("Error during graceful shutdown", e);
}
})).then().subscribeOn(Schedulers.boundedElastic());
}))
.then()
.subscribeOn(Schedulers.boundedElastic());
}
@Override