Skip to content

Commit

Permalink
fix: only retry 5xx Cloud SQL Admin API errors (#375)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jackwotherspoon authored Jul 12, 2024
1 parent f4a208b commit 67bff82
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
37 changes: 29 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/sqladmin-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ const defaultGaxiosHttpMethodsToRetry = [
function setupGaxiosConfig() {
gaxios.defaults = {
retryConfig: {
retry: 3,
retry: 5,
// Make sure to add POST to the list of default methods to retry
// since it's used in IAM generateAccessToken requests that needs retry
httpMethodsToRetry: ['POST', ...defaultGaxiosHttpMethodsToRetry],
// Should retry on non-http error codes such as ECONNRESET, ETIMEOUT, etc
noResponseRetries: 3,
// Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
statusCodesToRetry: [[500, 599]],
// The amount of time to initially delay the retry, in ms. Defaults to 100ms.
retryDelay: 200,
// The multiplier by which to increase the delay time between the
// completion of failed requests, and the initiation of the subsequent
// retrying request. Defaults to 2.
retryDelayMultiplier: 1.618,
},
};
}
Expand Down

0 comments on commit 67bff82

Please sign in to comment.