fix(komga): better error handling of sse connections

This commit is contained in:
Gauthier Roebroeck 2023-11-13 13:12:47 +08:00
parent bc49ce46e0
commit ab34781e9f
2 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,6 @@ plugins {
kotlin("plugin.spring")
kotlin("kapt")
}
// 3.1.3+ breaks SSE - https://github.com/spring-projects/spring-framework/issues/31140
id("org.springframework.boot") version "3.1.2"
id("com.gorylenko.gradle-git-properties") version "2.4.1"
id("nu.studer.jooq") version "8.2.1"

View File

@ -50,7 +50,8 @@ class SseController(
if (!acceptingConnections) throw IllegalStateException("Server is shutting down, not accepting new SSE connections")
val emitter = SseEmitter()
emitter.onCompletion { synchronized(emitters) { emitters.remove(emitter) } }
emitter.onTimeout { emitter.complete() }
emitter.onTimeout { synchronized(emitters) { emitters.remove(emitter) } }
emitter.onError { synchronized(emitters) { emitters.remove(emitter) } }
emitters[emitter] = principal.user
return emitter
}