mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-20 13:21:48 +08:00
fix: Pull 增量同步增加 60 秒重叠窗口避免消息丢失
lastPullAt 原先直接使用 Date.now(),在时钟偏差或迟到消息场景下 可能导致消息被跳过。现在减去 60 秒重叠窗口,依靠去重机制吸收 重复数据,确保不丢消息。 Made-with: Cursor
This commit is contained in:
@@ -234,6 +234,7 @@ async function importTempFile(baseUrl: string, sess: ImportSession, tempFile: st
|
||||
|
||||
const MAX_PAGES_PER_PULL = 50
|
||||
const DEFAULT_PULL_LIMIT = 1000
|
||||
const PULL_OVERLAP_SECONDS = 60
|
||||
|
||||
interface PullSessionResult {
|
||||
success: boolean
|
||||
@@ -337,7 +338,7 @@ async function executePullSession(sourceId: string, ds: DataSource, sess: Import
|
||||
}
|
||||
|
||||
updateImportSession(sourceId, sess.id, {
|
||||
lastPullAt: Math.floor(Date.now() / 1000),
|
||||
lastPullAt: Math.floor(Date.now() / 1000) - PULL_OVERLAP_SECONDS,
|
||||
lastStatus: 'success',
|
||||
lastNewMessages: totalNewMessages,
|
||||
lastError: '',
|
||||
|
||||
Reference in New Issue
Block a user