Skip to content

Commit 5ad0239

Browse files
committed
fix(sync): add 3.5s rate-limit delay between videos to prevent YouTube 429
1 parent 92fd6fe commit 5ad0239

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • apps/sanity/functions/sync-missing-youtube-transcripts

‎apps/sanity/functions/sync-missing-youtube-transcripts/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ export const handler = scheduledEventHandler(async ({ context }) => {
447447
`[Sync Missing YouTube Transcripts] Successfully linked ${transcriptId} to document ${doc._id}.`,
448448
);
449449
successCount++;
450+
451+
// Rate-limit delay: wait 3.5s between video requests to avoid YouTube 429 rate limits
452+
await new Promise((resolve) => setTimeout(resolve, 3500));
450453
} catch (err) {
451454
console.error(
452455
`[Sync Missing YouTube Transcripts] Failed to process ${doc._id} (${youtubeId}):`,

0 commit comments

Comments
 (0)