File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as clc from "colorette" ;
2
+ import * as utils from "../utils" ;
3
+ import { withHttpBackoff } from "./retryWithBackoff" ;
4
+
5
+ /**
6
+ * Convenience wrapper for Cloud Functions deploy operations.
7
+ * Retries **only** on HTTP 429 and logs a clear message.
8
+ */
9
+ export function with429Backoff < T > (
10
+ op : "create" | "update" | "delete" | "generateUploadUrl" ,
11
+ resourceName : string ,
12
+ thunk : ( ) => Promise < T > ,
13
+ ) {
14
+ return withHttpBackoff ( thunk , {
15
+ statuses : [ 429 ] ,
16
+ onRetry : ( { attempt, maxAttempts } ) => {
17
+ utils . logLabeledWarning (
18
+ "functions" ,
19
+ `${ clc . bold ( clc . yellow ( "429 (Quota Exceeded)" ) ) } on ${ op } ${ resourceName } ; retrying (attempt ${ attempt } ${ maxAttempts ? `/${ maxAttempts } ` : "" } )…` ,
20
+ ) ;
21
+ } ,
22
+ } ) ;
23
+ }
You can’t perform that action at this time.
0 commit comments