fix(polling): fix Drive pre-check never activating in Sheets poller

isDriveFileUnchanged short-circuited when lastModifiedTime was
undefined, never calling the Drive API — so currentModifiedTime
was never populated, creating a permanent chicken-and-egg loop.
Now always calls the Drive API and returns the modifiedTime
regardless of whether there's a previous value to compare against.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Waleed Latif
2026-04-09 14:18:44 -07:00
committed by waleed
parent a89841392f
commit 43ce2cc5cd

View File

@@ -226,13 +226,13 @@ async function isDriveFileUnchanged(
requestId: string,
logger: ReturnType<typeof import('@sim/logger').createLogger>
): Promise<{ unchanged: boolean; currentModifiedTime?: string }> {
if (!lastModifiedTime) return { unchanged: false }
try {
const currentModifiedTime = await getDriveFileModifiedTime(accessToken, spreadsheetId, logger)
if (!lastModifiedTime || !currentModifiedTime) {
return { unchanged: false, currentModifiedTime }
}
return { unchanged: currentModifiedTime === lastModifiedTime, currentModifiedTime }
} catch (error) {
// If Drive check fails, proceed with Sheets API (don't skip)
logger.warn(`[${requestId}] Drive modifiedTime check failed, proceeding with Sheets API`)
return { unchanged: false }
}