mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(polling): don't advance state when all events fail across sheets, calendar, drive handlers
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user