fix: KeyList TDZ crash and connection state desync

- Move filteredKeys computed before useVirtualizer in KeyList.vue to
  fix ReferenceError (Cannot access 'filteredKeys' before initialization)
  that crashed the component setup and cascaded into '.t is not a
  function' render errors.
- Wrap getInfo in try-catch in connection store connect() to clean up
  connectedIds/activeId when the client is lost between connect and
  getInfo, preventing a state where isConnected is true but no Redis
  client exists in the main process.
This commit is contained in:
2026-07-08 07:11:28 +08:00
parent baa8917eae
commit 76f35ae1f1
2 changed files with 18 additions and 8 deletions
+10 -1
View File
@@ -131,7 +131,16 @@ export const useConnectionStore = defineStore('connection', () => {
if (result.success) {
connectedIds.value.push(conn.id)
activeId.value = conn.id
serverInfoMap.value[conn.id] = await window.electronAPI.redis.getInfo(conn.id)
try {
serverInfoMap.value[conn.id] = await window.electronAPI.redis.getInfo(conn.id)
} catch {
// Client was lost between connect and getInfo — clean up to avoid
// leaving the renderer in a state where isConnected is true but no
// actual Redis client exists in the main process.
await disconnectById(conn.id)
error.value = 'Connection established but server info unavailable'
return
}
// Restore last selected DB for this connection
const lastDb = lastDbMap.value[conn.id] ?? 0
if (lastDb !== 0) {