Skip to content

Commit 67bff82

Browse files
fix: only retry 5xx Cloud SQL Admin API errors (#375)
This commit fixes the retry behavior of the two SQL Admin API calls. Any response that results in a 50x error will now be retried up to 5 times with exponential backoff. Using gaxios default exponential backoff. Previously the Node Connector was only retrying 3 times and for all error codes. Updating gaxios version to have newer params available.
1 parent f4a208b commit 67bff82

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

package-lock.json

Lines changed: 29 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sqladmin-fetcher.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,20 @@ const defaultGaxiosHttpMethodsToRetry = [
5151
function setupGaxiosConfig() {
5252
gaxios.defaults = {
5353
retryConfig: {
54-
retry: 3,
54+
retry: 5,
5555
// Make sure to add POST to the list of default methods to retry
5656
// since it's used in IAM generateAccessToken requests that needs retry
5757
httpMethodsToRetry: ['POST', ...defaultGaxiosHttpMethodsToRetry],
5858
// Should retry on non-http error codes such as ECONNRESET, ETIMEOUT, etc
5959
noResponseRetries: 3,
60+
// Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
61+
statusCodesToRetry: [[500, 599]],
62+
// The amount of time to initially delay the retry, in ms. Defaults to 100ms.
63+
retryDelay: 200,
64+
// The multiplier by which to increase the delay time between the
65+
// completion of failed requests, and the initiation of the subsequent
66+
// retrying request. Defaults to 2.
67+
retryDelayMultiplier: 1.618,
6068
},
6169
};
6270
}

0 commit comments

Comments
 (0)