修复潜在同步问题

This commit is contained in:
lyswhut
2023-08-21 13:57:36 +08:00
parent 53bc50d05c
commit 72fe8f3af1
4 changed files with 28 additions and 11 deletions
+7 -2
View File
@@ -219,9 +219,14 @@ export const connect = (urlInfo: LX.Sync.Client.UrlInfo, keyInfo: LX.Sync.Client
})
client.addEventListener('close', ({ code }) => {
const err = new Error('closed')
for (const handler of closeEvents) void handler(err)
handleDisconnection()
try {
for (const handler of closeEvents) void handler(err)
} catch (err: any) {
log.error(err?.message)
}
closeEvents = []
handleDisconnection()
message2read.onDestroy()
switch (code) {
case SYNC_CLOSE_CODE.normal:
// case SYNC_CLOSE_CODE.failed: