fix(polling): don't advance state when all events fail across sheets, calendar, drive handlers

This commit is contained in:
waleed
2026-04-09 16:33:39 -07:00
parent d32e1cbb81
commit a8baa49450
3 changed files with 10 additions and 10 deletions

View File

@@ -140,8 +140,10 @@ export const googleCalendarPollingHandler: PollingProviderHandler = {
logger
)
// Use the latest `updated` value from response to avoid clock skew
const newTimestamp = latestUpdated || now.toISOString()
const newTimestamp =
processedCount === 0 && failedCount > 0
? config.lastCheckedTimestamp
: latestUpdated || now.toISOString()
await updateWebhookProviderConfig(webhookId, { lastCheckedTimestamp: newTimestamp }, logger)
if (failedCount > 0 && processedCount === 0) {

View File

@@ -151,9 +151,13 @@ export const googleDrivePollingHandler: PollingProviderHandler = {
MAX_KNOWN_FILE_IDS
)
const allFailed = processedCount === 0 && failedCount > 0
await updateWebhookProviderConfig(
webhookId,
{ pageToken: newStartPageToken, knownFileIds: mergedKnownIds },
{
pageToken: allFailed ? config.pageToken : newStartPageToken,
knownFileIds: allFailed ? existingKnownIds : mergedKnownIds,
},
logger
)

View File

@@ -182,14 +182,8 @@ export const googleSheetsPollingHandler: PollingProviderHandler = {
logger
)
// Advance row count only by successfully processed rows so failed rows
// can be retried on the next poll cycle. Idempotency deduplicates the
// already-processed rows when they are re-fetched.
const rowsAdvanced = failedCount > 0 ? processedCount : rowsToFetch
const rowsAdvanced = failedCount > 0 ? 0 : rowsToFetch
const newLastKnownRowCount = config.lastKnownRowCount + rowsAdvanced
// When batching (more rows than maxRowsPerPoll) or retrying failed rows,
// keep the old lastModifiedTime so the Drive pre-check doesn't skip
// remaining/retried rows on the next poll.
const hasRemainingOrFailed = rowsAdvanced < newRowCount
await updateWebhookProviderConfig(
webhookId,