Handle WebSocket session removal on channel closure

Add `removeSession` calls in WebSocket exception handling blocks to ensure proper session cleanup when a `ClosedReceiveChannelException` occurs. Prevents potential resource leaks and ensures consistency across WebSocket routes.
This commit is contained in:
dalbodeule 2025-04-24 14:56:00 +09:00
parent 83cb68b63f
commit 0e8462eaf1
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
3 changed files with 3 additions and 0 deletions

View File

@ -151,6 +151,7 @@ fun Routing.wsSongListRoutes() {
} }
} catch (e: ClosedReceiveChannelException) { } catch (e: ClosedReceiveChannelException) {
logger.error("Error in WebSocket: ${e.message}") logger.error("Error in WebSocket: ${e.message}")
removeSession(uid)
} }
} }

View File

@ -110,6 +110,7 @@ fun Routing.wsSongRoutes() {
} }
} catch(e: ClosedReceiveChannelException) { } catch(e: ClosedReceiveChannelException) {
logger.error("Error in WebSocket: ${e.message}") logger.error("Error in WebSocket: ${e.message}")
removeSession(uid, this)
} }
} }

View File

@ -87,6 +87,7 @@ fun Routing.wsTimerRoutes() {
} }
} catch(e: ClosedReceiveChannelException) { } catch(e: ClosedReceiveChannelException) {
logger.error("Error in WebSocket: ${e.message}") logger.error("Error in WebSocket: ${e.message}")
removeSession(uid, this)
} }
} }