Skip to content

Commit 1ba6339

Browse files
committed
fix(trigger): treat Drive rate limits as success to preserve failure budget
1 parent 0f503f6 commit 1ba6339

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ export const googleDrivePollingHandler: PollingProviderHandler = {
180180
)
181181
return 'success'
182182
}
183+
if (error instanceof Error && error.name === 'DriveRateLimitError') {
184+
await markWebhookSuccess(webhookId, logger)
185+
logger.warn(
186+
`[${requestId}] Drive API rate limited for webhook ${webhookId}, skipping to retry next poll cycle`
187+
)
188+
return 'success'
189+
}
183190
logger.error(`[${requestId}] Error processing Google Drive webhook ${webhookId}:`, error)
184191
await markWebhookFailed(webhookId, logger)
185192
return 'failure'
@@ -207,9 +214,9 @@ async function getStartPageToken(
207214
const status = response.status
208215
const errorData = await response.json().catch(() => ({}))
209216
if (status === 403 || status === 429) {
210-
throw new Error(
211-
`Drive API rate limit (${status}) — skipping to retry next poll cycle: ${JSON.stringify(errorData)}`
212-
)
217+
const err = new Error(`Drive API rate limit (${status}): ${JSON.stringify(errorData)}`)
218+
err.name = 'DriveRateLimitError'
219+
throw err
213220
}
214221
throw new Error(
215222
`Failed to get Drive start page token: ${status} - ${JSON.stringify(errorData)}`
@@ -261,9 +268,9 @@ async function fetchChanges(
261268
throw err
262269
}
263270
if (status === 403 || status === 429) {
264-
throw new Error(
265-
`Drive API rate limit (${status}) — skipping to retry next poll cycle: ${JSON.stringify(errorData)}`
266-
)
271+
const err = new Error(`Drive API rate limit (${status}): ${JSON.stringify(errorData)}`)
272+
err.name = 'DriveRateLimitError'
273+
throw err
267274
}
268275
throw new Error(`Failed to fetch Drive changes: ${status} - ${JSON.stringify(errorData)}`)
269276
}

0 commit comments

Comments
 (0)