mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
fix: Retry socket authentication on auth failure
When socket authentication fails (e.g., race condition when token is not yet loaded from storage), the client now retries authentication after a short delay. This fixes the issue where: - Login page shows spinning icon forever - Playback fails with 'invalid token' errors - Socket stays unauthenticated after transient failures The fix adds a 500ms retry delay that allows time for the token to become available (e.g., after hydration from localStorage). Fixes #5101
This commit is contained in:
parent
6d3404272c
commit
7ea0736111
1 changed files with 12 additions and 0 deletions
|
|
@ -143,6 +143,18 @@ export default {
|
|||
authFailed(payload) {
|
||||
console.error('[SOCKET] auth failed', payload.message)
|
||||
this.isSocketAuthenticated = false
|
||||
|
||||
// Retry authentication after a short delay (e.g., token might not be loaded yet)
|
||||
// This handles race conditions where socket connects before token is available
|
||||
setTimeout(() => {
|
||||
if (!this.isSocketAuthenticated && this.socket?.connected) {
|
||||
const token = this.$store.getters['user/getToken']
|
||||
if (token) {
|
||||
console.log('[SOCKET] Retrying authentication after auth failure')
|
||||
this.socket.emit('auth', token)
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
},
|
||||
init(payload) {
|
||||
console.log('Init Payload', payload)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue