diff --git a/src/stores/streaming.js b/src/stores/streaming.js index dae047f46..554d6a6b5 100644 --- a/src/stores/streaming.js +++ b/src/stores/streaming.js @@ -108,7 +108,19 @@ export const useStreamingStore = defineStore('streaming', { } }, initSocket(initial) { - if (this.socket) throw new Error('Socket already exists!') + if (this.socket) { + console.error( + "Socket already exists! This shouldn't happen! Force-closing the socket just in case", + ) + try { + this.socket.close() + } catch (e) { + console.error( + "Error closing existing socket that shouldn't be there. Welp. Moving on.", + e, + ) + } + } this.state = initial ? WSConnectionStatus.STARTING_INITIAL @@ -130,7 +142,9 @@ export const useStreamingStore = defineStore('streaming', { this.socket.addEventListener('error', this.onError) }, stopSocket() { - this.socket.close() + if (this.socket == null) + console.error("Socket is already stopped! This shouldn't happen!") + this.socket?.close() this.socket = null this.state = WSConnectionStatus.CLOSED this.retrying = false @@ -235,7 +249,7 @@ export const useStreamingStore = defineStore('streaming', { ) setTimeout(() => { - if (this.retrying) return // retry aborted (i.e. due to logout) + if (!this.retrying) return // retry aborted (i.e. due to logout) this.initSocket() }, retryTimeout(this.retryMultiplier)) diff --git a/src/stores/users.js b/src/stores/users.js index da35dc3a0..c9445a65d 100644 --- a/src/stores/users.js +++ b/src/stores/users.js @@ -278,9 +278,8 @@ export const useUsersStore = defineStore('users', { map.set(identifier, promise) - const result = await promise - try { + const result = await promise if (result) { const { id, screen_name } = result