fix:尝试修复了新手引导闪退的问题

This commit is contained in:
xuncha
2026-01-21 19:02:14 +08:00
parent d5a2e2bb62
commit 348f6c81bf
3 changed files with 72 additions and 4 deletions

View File

@@ -58,12 +58,24 @@ export class WcdbService {
})
this.worker.on('error', (err) => {
// Worker error
// Worker 发生错误,需要 reject 所有 pending promises
console.error('WCDB Worker 错误:', err)
const errorMsg = err instanceof Error ? err.message : String(err)
for (const [id, p] of this.pending) {
p.reject(new Error(`Worker 错误: ${errorMsg}`))
}
this.pending.clear()
})
this.worker.on('exit', (code) => {
// Worker 退出,需要 reject 所有 pending promises
if (code !== 0) {
// Worker exited with error
console.error('WCDB Worker 异常退出,退出码:', code)
const errorMsg = `Worker 异常退出 (退出码: ${code})。可能是 DLL 加载失败,请检查是否安装了 Visual C++ Redistributable。`
for (const [id, p] of this.pending) {
p.reject(new Error(errorMsg))
}
this.pending.clear()
}
this.worker = null
})