Skip to content

Commit e14ff04

Browse files
committed
fix(polling): don't advance state when all events fail across sheets, calendar, drive handlers
1 parent ee070fb commit e14ff04

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

apps/sim/lib/webhooks/polling/google-calendar.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ export const googleCalendarPollingHandler: PollingProviderHandler = {
140140
logger
141141
)
142142

143-
// Use the latest `updated` value from response to avoid clock skew
144-
const newTimestamp = latestUpdated || now.toISOString()
143+
const newTimestamp =
144+
processedCount === 0 && failedCount > 0
145+
? config.lastCheckedTimestamp
146+
: latestUpdated || now.toISOString()
145147
await updateWebhookProviderConfig(webhookId, { lastCheckedTimestamp: newTimestamp }, logger)
146148

147149
if (failedCount > 0 && processedCount === 0) {

apps/sim/lib/webhooks/polling/google-drive.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,13 @@ export const googleDrivePollingHandler: PollingProviderHandler = {
151151
MAX_KNOWN_FILE_IDS
152152
)
153153

154+
const allFailed = processedCount === 0 && failedCount > 0
154155
await updateWebhookProviderConfig(
155156
webhookId,
156-
{ pageToken: newStartPageToken, knownFileIds: mergedKnownIds },
157+
{
158+
pageToken: allFailed ? config.pageToken : newStartPageToken,
159+
knownFileIds: allFailed ? existingKnownIds : mergedKnownIds,
160+
},
157161
logger
158162
)
159163

apps/sim/lib/webhooks/polling/google-sheets.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,8 @@ export const googleSheetsPollingHandler: PollingProviderHandler = {
182182
logger
183183
)
184184

185-
// Advance row count only by successfully processed rows so failed rows
186-
// can be retried on the next poll cycle. Idempotency deduplicates the
187-
// already-processed rows when they are re-fetched.
188-
const rowsAdvanced = failedCount > 0 ? processedCount : rowsToFetch
185+
const rowsAdvanced = failedCount > 0 ? 0 : rowsToFetch
189186
const newLastKnownRowCount = config.lastKnownRowCount + rowsAdvanced
190-
// When batching (more rows than maxRowsPerPoll) or retrying failed rows,
191-
// keep the old lastModifiedTime so the Drive pre-check doesn't skip
192-
// remaining/retried rows on the next poll.
193187
const hasRemainingOrFailed = rowsAdvanced < newRowCount
194188
await updateWebhookProviderConfig(
195189
webhookId,

0 commit comments

Comments
 (0)