From d488612c277479b9b77a9a941b1b8961b2fd7fa6 Mon Sep 17 00:00:00 2001 From: Jokul Date: Sat, 4 Jul 2026 20:06:43 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=B7=BB=E5=8A=A0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ipc-handlers.ts | 4 +++- src/main/redis-service.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/ipc-handlers.ts b/src/main/ipc-handlers.ts index 95aaa51..53f82be 100644 --- a/src/main/ipc-handlers.ts +++ b/src/main/ipc-handlers.ts @@ -70,10 +70,12 @@ export function registerIpcHandlers(): void { // Redis ipcMain.handle('redis:connect', async (_e, id: string, opts) => { try { + console.log(`[IPC] redis:connect id=${id}`, opts) await redisService.connect(id, opts) return { success: true } } catch (err: any) { - return { success: false, error: err.message } + console.error(`[IPC] redis:connect error:`, err.message) + return { success: false, error: err.message || String(err) } } }) ipcMain.handle('redis:disconnect', async (_e, id: string) => { diff --git a/src/main/redis-service.ts b/src/main/redis-service.ts index 2abd7f5..72185fc 100644 --- a/src/main/redis-service.ts +++ b/src/main/redis-service.ts @@ -53,14 +53,17 @@ export async function connect(id: string, opts: ConnectionOptions): Promise { + console.log(`[Redis] Connecting to ${opts.host}:${opts.port}...`) const redis = new Redis(buildRedisOptions(opts)) redis.once('ready', () => { + console.log(`[Redis] Connected to ${opts.host}:${opts.port}`) clients.set(id, redis) resolve() }) redis.once('error', (err: Error) => { + console.error(`[Redis] Connection error:`, err.message) redis.disconnect() reject(err) }) @@ -68,8 +71,9 @@ export async function connect(id: string, opts: ConnectionOptions): Promise { if (!clients.has(id)) { + console.error(`[Redis] Connection timeout`) redis.disconnect() - reject(new Error('Connection timeout')) + reject(new Error('连接超时,请检查主机和端口')) } }, 12000) })