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:
@@ -27,6 +27,14 @@ const contextMenu = ref<{ visible: boolean; x: number; y: number; key: string }>
|
||||
// Shift+Click range selection
|
||||
const lastClickedIndex = ref<number>(-1)
|
||||
|
||||
// Filtered keys (must be declared before useVirtualizer which references it)
|
||||
const filteredKeys = computed(() => {
|
||||
const keys = keyStore.keys.map(k => k.name)
|
||||
return filterText.value
|
||||
? keys.filter(k => k.includes(filterText.value))
|
||||
: keys
|
||||
})
|
||||
|
||||
// Virtual scrolling
|
||||
const scrollRef = ref<HTMLElement>()
|
||||
const useVirtualization = computed(() => viewMode.value === 'list' && filteredKeys.value.length > 100)
|
||||
@@ -404,13 +412,6 @@ function toggleFolder(path: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const filteredKeys = computed(() => {
|
||||
const keys = keyStore.keys.map(k => k.name)
|
||||
return filterText.value
|
||||
? keys.filter(k => k.includes(filterText.value))
|
||||
: keys
|
||||
})
|
||||
|
||||
const treeData = computed<TreeNode[]>(() => {
|
||||
const separator = connStore.activeConnection?.separator || ':'
|
||||
const root: TreeNode[] = []
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user