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
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}")
} finally {
removeSession(uid) 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}")
} finally {
removeSession(uid, this) 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}")
} finally {
removeSession(uid, this) removeSession(uid, this)
} }
} }