-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Preserve quota statuses so function deploy retries work #9497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -216,6 +216,7 @@ interface GenerateUploadUrlResponse { | |||||||
| * @param err The error returned from the operation. | ||||||||
| */ | ||||||||
| function functionsOpLogReject(func: InputCloudFunction, type: string, err: any): void { | ||||||||
| const status = err?.context?.response?.statusCode || err?.status; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the v1 file,
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error paths feeding these handlers already give us numeric status codes: |
||||||||
| // Sniff for runtime validation errors and log a more user-friendly warning. | ||||||||
| if (err?.message?.includes("Runtime validation errors")) { | ||||||||
| const capturedMessage = captureRuntimeValidationError(err.message); | ||||||||
|
|
@@ -238,7 +239,7 @@ function functionsOpLogReject(func: InputCloudFunction, type: string, err: any): | |||||||
| ); | ||||||||
| } else { | ||||||||
| utils.logLabeledWarning("functions", `${err?.message}`); | ||||||||
| if (err?.context?.response?.statusCode === 429) { | ||||||||
| if (status === 429) { | ||||||||
| utils.logLabeledWarning( | ||||||||
| "functions", | ||||||||
| `Got "Quota Exceeded" error while trying to ${type} ${func.name}. Waiting to retry...`, | ||||||||
|
|
@@ -261,7 +262,7 @@ function functionsOpLogReject(func: InputCloudFunction, type: string, err: any): | |||||||
| } | ||||||||
| throw new FirebaseError(`Failed to ${type} function ${func.name}`, { | ||||||||
| original: err, | ||||||||
| status: err?.context?.response?.statusCode, | ||||||||
| status, | ||||||||
| context: { function: func.name }, | ||||||||
| }); | ||||||||
| } | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
err.statusis expected to be a number fromFirebaseError, the type oferrisany, which doesn't guarantee this. Iferr.statuswere a non-numeric string (e.g., an error status string like 'RESOURCE_EXHAUSTED'), it would be assigned tostatus. This could lead to incorrect behavior, asstatus === 429would fail and a non-numeric value would be passed to theFirebaseErrorconstructor, which expects a number. To make this more robust, consider ensuring the extracted value is a number.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error paths feeding these handlers already give us numeric status codes:
responseToErrorsetsstatusCodeas a number, gax errors use numericcode, andFirebaseErrorstores a numericstatus(default 500). If a strange upstream ever handed us a string like"RESOURCE_EXHAUSTED", the 429 check would simply skip the quota branch and theFirebaseErrorwould carry that string, but it wouldn’t change retry behavior because the executor’sparseErrorCodestill looks for numeric codes.