Fix session cleanup in WebSocket routes

Add missing `finally` blocks to ensure session removal in WebSocket routes after exceptions. This prevents potential memory leaks and ensures proper resource cleanup.
This commit is contained in:
dalbodeule
2025-04-24 15:01:12 +09:00
parent 0e8462eaf1
commit 17d8065a34
3 changed files with 3 additions and 0 deletions

View File

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

View File

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

View File

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