[Bug]: Stale, unclosed playback session overwrites newer progress on close
What happened?
When a playback session is left open (app closed/killed without explicitly stopping playback) and is only closed later by starting a new session for the same book, the stale session's last known progress overwrites the current, much newer progress — instead of being discarded or ignored.
What did you expect to happen?
Closing a stale/orphaned session should never overwrite progress that is newer than that session's own last known position. The server should compare timestamps (or updatedAt) before writing, and only apply the stale session's progress if it is actually more recent.
Steps to reproduce the issue
- Play an audiobook (Direct Play), progress correctly synced via sync at e.g. currentTime: 23595.956. Session A left open (app simply closed, not explicitly stopped).
- Later, a new session (Session B) is started for the same book. It correctly tracks and syncs progress forward, e.g. up to currentTime: 25879.466, confirmed both in the app history and in the ABS web UI (75%).
- Some time later, opening the book again triggers server log line: [PlaybackSessionManager] startSession: Closing open session for user "Veronika" — this is Session A (or an even older session) finally being closed.
- Immediately after, the book's progress on the server has reverted to Session A's old value (~13490s / 39%), discarding the correct, newer progress from Session B. The new playback session then starts from this stale position.
This has now been reproduced three times with matching timestamps between the Android app's local log (sync events) and the server log (startSession: Closing open session).
Audiobookshelf version
v2.37.0
How are you running audiobookshelf?
Docker
What OS is your Audiobookshelf server hosted from?
Linux
If the issue is being seen in the UI, what browsers are you seeing the problem on?
None
Logs
APP Log
09/29/2026 17:16:56.746 [INFO] load: AbsLogger plugin initialized
09/29/2026 17:16:57.443 [INFO] mounted: initializing first load (android v0.14.2-beta)
09/29/2026 17:16:57.632 [INFO] mounted: Server not connected, attempt connection
09/29/2026 17:16:57.640 [INFO] attemptConnection: Got server config, attempt authorize
09/29/2026 17:16:58.235 [INFO] attemptConnection: Successful connection to last saved server config
09/29/2026 17:16:58.263 [INFO] initLibraries loading library Hörbücher
09/29/2026 17:16:58.704 [INFO] Calling syncLocalSessions
09/29/2026 17:16:58.707 [INFO] [ApiHandler] syncLocalMediaProgressForUser: Server connection
09/29/2026 17:16:58.708 [INFO] [ApiHandler] syncLocalMediaProgressForUser: No local media progress to sync
09/29/2026 17:16:58.710 [INFO] syncLocalSessionsWithServer: No saved local playback sessions to send to server.
09/29/2026 17:16:58.720 [INFO] syncLocalSessions: Successfully synced local sessions
09/29/2026 17:16:58.897 [INFO] mounted: fully initialized
09/29/2026 17:17:21.899 [INFO] playLibraryItem: Received play request for library item 22329e0e-f7c1-46e3-90b7-47ad5714ba66
09/29/2026 17:17:21.917 [INFO] prepareLibraryItem: lid=22329e0e-f7c1-46e3-90b7-47ad5714ba66, startTimeOverride=null, playbackRate=1.0
09/29/2026 17:17:22.780 [INFO] preparePlayer: Started playback session for item 22329e0e-f7c1-46e3-90b7-47ad5714ba66. MediaPlayer exo-player
09/29/2026 17:17:22.783 [INFO] preparePlayer: Direct playing item 22329e0e-f7c1-46e3-90b7-47ad5714ba66.
09/29/2026 17:17:24.787 [INFO] sync: Sending progress sync to server (currentTime: 13490.987) (session id: 09ee3b7c-e146-40e2-b2a5-8ca7501c5576)
09/29/2026 17:17:27.331 [INFO] sync: Successfully synced progress (currentTime: 13490.987) (session id: 09ee3b7c-e146-40e2-b2a5-8ca7501c5576)
09/29/2026 17:17:27.334 [INFO] userMediaProgressUpdate: Received updated media progress for current user from socket event. Media item id 1a643f75-a29c-4139-b140-e2f1efe9b27c
09/30/2026 06:11:25.360 [INFO] load: AbsLogger plugin initialized
09/30/2026 06:11:26.277 [INFO] mounted: initializing first load (android v0.14.2-beta)
09/30/2026 06:11:26.605 [INFO] mounted: Server not connected, attempt connection
09/30/2026 06:11:26.614 [INFO] attemptConnection: Got server config, attempt authorize
09/30/2026 06:11:32.637 [ERROR] attemptConnection: Server auth failed
09/30/2026 06:11:32.644 [INFO] mounted: fully initialized
09/30/2026 06:12:03.489 [INFO] mounted: initializing first load (android v0.14.2-beta)
09/30/2026 06:12:03.516 [INFO] mounted: Server connected, init libraries
09/30/2026 06:12:06.930 [INFO] initLibraries loading library Hörbücher
09/30/2026 06:12:16.988 [INFO] Calling syncLocalSessions
09/30/2026 06:12:16.992 [INFO] [ApiHandler] syncLocalMediaProgressForUser: Server connection
09/30/2026 06:12:16.998 [INFO] [ApiHandler] syncLocalMediaProgressForUser: No local media progress to sync
09/30/2026 06:12:17.005 [INFO] syncLocalSessionsWithServer: No saved local playback sessions to send to server.
09/30/2026 06:12:17.496 [INFO] syncLocalSessions: Successfully synced local sessions
09/30/2026 06:12:17.503 [INFO] mounted: fully initialized
09/30/2026 06:13:57.446 [INFO] playLibraryItem: Received play request for library item 22329e0e-f7c1-46e3-90b7-47ad5714ba66
09/30/2026 06:13:57.472 [INFO] prepareLibraryItem: lid=22329e0e-f7c1-46e3-90b7-47ad5714ba66, startTimeOverride=null, playbackRate=1.0
09/30/2026 06:13:57.963 [INFO] preparePlayer: Started playback session for item 22329e0e-f7c1-46e3-90b7-47ad5714ba66. MediaPlayer exo-player
09/30/2026 06:13:57.968 [INFO] preparePlayer: Direct playing item 22329e0e-f7c1-46e3-90b7-47ad5714ba66.
09/30/2026 06:14:08.014 [INFO] sync: Sending progress sync to server (currentTime: 13492.129) (session id: 9d0de623-2e5d-4803-9878-49672dc82162)
09/30/2026 06:14:08.444 [INFO] sync: Successfully synced progress (currentTime: 13492.129) (session id: 9d0de623-2e5d-4803-9878-49672dc82162)
09/30/2026 06:14:08.449 [INFO] userMediaProgressUpdate: Received updated media progress for current user from socket event. Media item id 1a643f75-a29c-4139-b140-e2f1efe9b27c
09/30/2026 06:22:16.521 [INFO] sync: Sending progress sync to server (currentTime: 25879.466) (session id: 9d0de623-2e5d-4803-9878-49672dc82162)
09/30/2026 06:22:16.953 [INFO] sync: Successfully synced progress (currentTime: 25879.466) (session id: 9d0de623-2e5d-4803-9878-49672dc82162)
09/30/2026 06:22:16.956 [INFO] userMediaProgressUpdate: Received updated media progress for current user from socket event. Media item id 1a643f75-a29c-4139-b140-e2f1efe9b27c
10/01/2026 10:27:01.658 [INFO] cleanLogs: Removed 23 logs older than 48 hours
10/01/2026 10:27:01.659 [INFO] load: AbsLogger plugin initialized
10/01/2026 10:27:03.309 [INFO] mounted: initializing first load (android v0.14.2-beta)
10/01/2026 10:27:03.796 [INFO] mounted: Server not connected, attempt connection
10/01/2026 10:27:03.811 [INFO] attemptConnection: Got server config, attempt authorize
10/01/2026 10:27:05.563 [INFO] attemptConnection: Successful connection to last saved server config
10/01/2026 10:27:05.833 [INFO] initLibraries loading library Hörbücher
10/01/2026 10:27:07.974 [INFO] Calling syncLocalSessions
10/01/2026 10:27:07.977 [INFO] [ApiHandler] syncLocalMediaProgressForUser: Server connection
10/01/2026 10:27:07.978 [INFO] [ApiHandler] syncLocalMediaProgressForUser: No local media progress to sync
10/01/2026 10:27:07.980 [INFO] syncLocalSessionsWithServer: No saved local playback sessions to send to server.
10/01/2026 10:27:08.150 [INFO] syncLocalSessions: Successfully synced local sessions
10/01/2026 10:27:08.153 [INFO] mounted: fully initialized
10/01/2026 10:30:14.436 [INFO] playLibraryItem: Received play request for library item 22329e0e-f7c1-46e3-90b7-47ad5714ba66
10/01/2026 10:30:14.465 [INFO] prepareLibraryItem: lid=22329e0e-f7c1-46e3-90b7-47ad5714ba66, startTimeOverride=null, playbackRate=1.0
10/01/2026 10:30:15.750 [INFO] preparePlayer: Started playback session for item 22329e0e-f7c1-46e3-90b7-47ad5714ba66. MediaPlayer exo-player
10/01/2026 10:30:15.755 [INFO] preparePlayer: Direct playing item 22329e0e-f7c1-46e3-90b7-47ad5714ba66.
10/01/2026 10:30:21.225 [INFO] sync: Sending progress sync to server (currentTime: 13492.075) (session id: 8f831067-1907-4879-b67b-66593d92fafb)
10/01/2026 10:30:21.696 [INFO] sync: Successfully synced progress (currentTime: 13492.075) (session id: 8f831067-1907-4879-b67b-66593d92fafb)
10/01/2026 10:30:21.727 [INFO] userMediaProgressUpdate: Received updated media progress for current user from socket event. Media item id 1a643f75-a29c-4139-b140-e2f1efe9b27c
Server log
2026-10-01 10:26:59.956 INFO [MediaProgress] Marking media progress as finished because time remaining (-0.004676000000017666) is less than 10 seconds (media item 12df0d80-d7e5-4327-8510-14454d2ff4c8)
2026-10-01 10:27:02.074 INFO [MediaProgress] Marking media progress as finished because time remaining (-0.008972999999969034) is less than 10 seconds (media item 54adab65-968c-40a1-8837-b6797b589392)
2026-10-01 10:27:03.580 INFO [SocketAuthority] Socket Connected to /socket.io Erxo03Dn-_OSxdK_AAA1
2026-10-01 10:27:48.406 INFO [SocketAuthority] Socket Erxo03Dn-_OSxdK_AAA1 disconnected from client "Veronika" after 44826ms (Reason: transport close)
2026-10-01 10:29:05.819 INFO [SocketAuthority] Socket Connected to /socket.io cuNtV4fq9EJWwd82AAA3
2026-10-01 10:29:34.856 INFO [SocketAuthority] Socket cuNtV4fq9EJWwd82AAA3 disconnected from client "Veronika" after 29037ms (Reason: transport close)
2026-10-01 10:30:12.664 INFO [PlaybackSessionManager] startSession: Closing open session for user "Veronika" (Device: Pixel 7 SDK 37 / v0.14.1-beta)
2026-10-01 10:30:15.193 INFO [SocketAuthority] Socket Connected to /socket.io MEGzyD0xzsCTAvh2AAA5
2026-10-01 10:31:27.173 INFO [SocketAuthority] Socket Connected to /audiobookshelf/socket.io 5NTI2MXoNC5hHfHMAAA7
2026-10-01 10:31:30.867 INFO [SocketAuthority] Socket 5NTI2MXoNC5hHfHMAAA7 disconnected from client "Veronika" after 3695ms (Reason: client namespace disconnect)
2026-10-01 10:31:31.721 INFO [TokenManager] Refresh token invalidated, 1 sessions deletedAdditional Notes
No response
Source: advplyr/audiobookshelf