From d32e1cbb81aab2d0a1d7dda7f15729967ad1adff Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 9 Apr 2026 14:52:32 -0700 Subject: [PATCH] fix(polling): remove unused variable and preserve lastModifiedTime on Drive API failure - Remove unused `now` variable from Google Drive polling handler - Preserve stored lastModifiedTime when Drive API pre-check fails (previously wrote undefined, disabling the optimization until the next successful Drive API call) --- apps/sim/lib/webhooks/polling/google-drive.ts | 1 - apps/sim/lib/webhooks/polling/google-sheets.ts | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/sim/lib/webhooks/polling/google-drive.ts b/apps/sim/lib/webhooks/polling/google-drive.ts index 7cfadea76c..2ea50a4274 100644 --- a/apps/sim/lib/webhooks/polling/google-drive.ts +++ b/apps/sim/lib/webhooks/polling/google-drive.ts @@ -87,7 +87,6 @@ export const googleDrivePollingHandler: PollingProviderHandler = { ) const config = webhookData.providerConfig as unknown as GoogleDriveWebhookConfig - const now = new Date() // First poll: get startPageToken and seed state if (!config.pageToken) { diff --git a/apps/sim/lib/webhooks/polling/google-sheets.ts b/apps/sim/lib/webhooks/polling/google-sheets.ts index 6216e65378..636a4d0654 100644 --- a/apps/sim/lib/webhooks/polling/google-sheets.ts +++ b/apps/sim/lib/webhooks/polling/google-sheets.ts @@ -95,7 +95,7 @@ export const googleSheetsPollingHandler: PollingProviderHandler = { webhookId, { lastKnownRowCount: currentRowCount, - lastModifiedTime: currentModifiedTime, + lastModifiedTime: currentModifiedTime ?? config.lastModifiedTime, lastCheckedTimestamp: now.toISOString(), }, logger @@ -118,7 +118,7 @@ export const googleSheetsPollingHandler: PollingProviderHandler = { webhookId, { lastKnownRowCount: currentRowCount, - lastModifiedTime: currentModifiedTime, + lastModifiedTime: currentModifiedTime ?? config.lastModifiedTime, lastCheckedTimestamp: now.toISOString(), }, logger @@ -195,7 +195,9 @@ export const googleSheetsPollingHandler: PollingProviderHandler = { webhookId, { lastKnownRowCount: newLastKnownRowCount, - lastModifiedTime: hasRemainingOrFailed ? config.lastModifiedTime : currentModifiedTime, + lastModifiedTime: hasRemainingOrFailed + ? config.lastModifiedTime + : (currentModifiedTime ?? config.lastModifiedTime), lastCheckedTimestamp: now.toISOString(), }, logger