File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " wrangler " : patch
3+ ---
4+
5+ Rate limit r2 bulk put
Original file line number Diff line number Diff line change @@ -569,9 +569,20 @@ export const r2BulkPutCommand = createCommand({
569569 }
570570 ) ;
571571 } else {
572+ // Cloudflare API rate limits
573+ // 1200 requests per 5 minutes
574+ // We add some headroom (100 requests) for other API usage
575+ // ref: https://developers.cloudflare.com/fundamentals/api/reference/limits/
576+ const API_RATE_LIMIT_WINDOWS_MS = 5 * 60 * 1_000 ; // 5 minutes
577+ const API_RATE_LIMIT_REQUESTS = 1_200 - 100 ;
578+
572579 const accountId = await requireAuth ( config ) ;
573580
574- const queue = new PQueue ( { concurrency } ) ;
581+ const queue = new PQueue ( {
582+ concurrency,
583+ interval : API_RATE_LIMIT_WINDOWS_MS ,
584+ intervalCap : API_RATE_LIMIT_REQUESTS ,
585+ } ) ;
575586
576587 await queue . addAll (
577588 entries . map ( ( entry , index ) => async ( ) => {
You can’t perform that action at this time.
0 commit comments