fix(sync): clear dead emitter and ignore IllegalStateException
Some checks failed
Deploy to OCIWP / deploy (push) Failing after 1m18s

This commit is contained in:
jade
2026-08-14 16:35:34 +09:00
parent 1411f39ffc
commit ac73a86979

View File

@@ -224,7 +224,8 @@ public class CustomWebMvcSseServerTransportProvider implements McpServerTranspor
}
} catch (Exception e) {
if (e.getClass().getSimpleName().contains("AsyncRequestNotUsableException") ||
(e.getCause() != null && e.getCause() instanceof java.io.IOException)) {
(e.getCause() != null && e.getCause() instanceof java.io.IOException) ||
(e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().contains("already completed"))) {
log.debug("SSE emitter is disconnected (expected in Warm Pool): {}", e.getMessage());
} else {
log.error("Error sending message to SSE emitter", e);
@@ -235,6 +236,10 @@ public class CustomWebMvcSseServerTransportProvider implements McpServerTranspor
this.emitter.completeWithError(e);
} catch (Exception ignored) {
// ignore already completed
} finally {
// 죽은 Emitter를 null로 초기화하여 다음 5초 주기 때 재시도하지 않도록 방지
// 클라이언트가 재연결하면 setEmitter(새 Emitter)를 통해 덮어씌워짐
this.emitter = null;
}
}
}