mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 15:25:50 +00:00
fix: 修复 getAvatarUrls 竞态导致 handle 为 null 的崩溃
在 await setImmediate 让出控制权前先捕获 handle, await 后重新校验 handle 是否仍有效,避免连接关闭后 向 koffi DLL 传入 null 导致 TypeError。
This commit is contained in:
@@ -1488,10 +1488,19 @@ export class WcdbCore {
|
||||
}
|
||||
|
||||
// 让出控制权,避免阻塞事件循环
|
||||
const handle = this.handle
|
||||
await new Promise(resolve => setImmediate(resolve))
|
||||
|
||||
// await 后 handle 可能已被关闭,需重新检查
|
||||
if (handle === null || this.handle !== handle) {
|
||||
if (Object.keys(resultMap).length > 0) {
|
||||
return { success: true, map: resultMap, error: '连接已断开' }
|
||||
}
|
||||
return { success: false, error: '连接已断开' }
|
||||
}
|
||||
|
||||
const outPtr = [null as any]
|
||||
const result = this.wcdbGetAvatarUrls(this.handle, JSON.stringify(toFetch), outPtr)
|
||||
const result = this.wcdbGetAvatarUrls(handle, JSON.stringify(toFetch), outPtr)
|
||||
|
||||
// DLL 调用后再次让出控制权
|
||||
await new Promise(resolve => setImmediate(resolve))
|
||||
|
||||
Reference in New Issue
Block a user