Skip to content

Commit ec7b46f

Browse files
DaxServerclaude
andcommitted
fix: use >= for same-second upload change detection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bac33ec commit ec7b46f

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

backend/src/core/handler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,9 @@ export class Handler {
640640
const poll = async () => {
641641
try {
642642
const current = await this.services.uploads.getLatestUploadUpdateTime(batchid)
643-
if (current && (!lastUpdateTime || current > lastUpdateTime)) {
643+
// Use >= to catch uploads that update within the same MySQL second as lastUpdateTime.
644+
// Only advance lastUpdateTime on strict > to avoid infinite re-polls at a stale timestamp.
645+
if (current && (!lastUpdateTime || current >= lastUpdateTime)) {
644646
const since = lastUpdateTime ?? new Date(0)
645647
const changed = await this.services.uploads.getUploadsByBatchChangedSince(batchid, since)
646648
if (changed.length > 0) {
@@ -651,7 +653,9 @@ export class Handler {
651653
nonce: nonce(),
652654
})
653655
}
654-
lastUpdateTime = current
656+
if (!lastUpdateTime || current > lastUpdateTime) {
657+
lastUpdateTime = current
658+
}
655659
}
656660
const [total, active] = await Promise.all([
657661
this.services.batches.countUploadsInBatch(batchid),

backend/src/db/dal/uploads.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
eq,
1212
getTableColumns,
1313
gt,
14+
gte,
1415
inArray,
1516
like,
1617
lt,
@@ -550,7 +551,7 @@ export class UploadService {
550551
return this.db
551552
.select(cols)
552553
.from(uploadRequests)
553-
.where(and(eq(uploadRequests.batchid, batchId), gt(uploadRequests.updated_at, since)))
554+
.where(and(eq(uploadRequests.batchid, batchId), gte(uploadRequests.updated_at, since)))
554555
.orderBy(asc(uploadRequests.id))
555556
}
556557

0 commit comments

Comments
 (0)