Comparing version 6.6.0 to 6.7.0
@@ -1,5 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Agent } from 'http'; | ||
@@ -17,3 +13,3 @@ import { URL } from 'url'; | ||
response?: GaxiosResponse<T> | undefined; | ||
error?: Error | NodeJS.ErrnoException | undefined; | ||
error?: (Error | NodeJS.ErrnoException) | undefined; | ||
/** | ||
@@ -52,3 +48,3 @@ * An Error code. | ||
static [Symbol.hasInstance](instance: unknown): boolean; | ||
constructor(message: string, config: GaxiosOptions, response?: GaxiosResponse<T> | undefined, error?: Error | NodeJS.ErrnoException | undefined); | ||
constructor(message: string, config: GaxiosOptions, response?: GaxiosResponse<T> | undefined, error?: (Error | NodeJS.ErrnoException) | undefined); | ||
} | ||
@@ -226,2 +222,17 @@ export interface Headers { | ||
retryBackoff?: (err: GaxiosError, defaultBackoffMs: number) => Promise<void>; | ||
/** | ||
* Time that the initial request was made. Users should not set this directly. | ||
*/ | ||
timeOfFirstRequest?: number; | ||
/** | ||
* The length of time to keep retrying in ms. The last sleep period will | ||
* be shortened as necessary, so that the last retry runs at deadline (and not | ||
* considerably beyond it). The total time starting from when the initial | ||
* request is sent, after which an error will be returned, regardless of the | ||
* retrying attempts made meanwhile. Defaults to Number.MAX_SAFE_INTEGER indicating to effectively | ||
* ignore totalTimeout. | ||
*/ | ||
totalTimeout?: number; | ||
maxRetryDelay?: number; | ||
retryDelayMultiplier?: number; | ||
} | ||
@@ -264,4 +275,4 @@ export type FetchImplementation = (input: FetchRequestInfo, init?: FetchRequestInit) => Promise<FetchResponse>; | ||
}): { | ||
config?: RedactableGaxiosOptions | undefined; | ||
response?: RedactableGaxiosResponse<T> | undefined; | ||
config?: RedactableGaxiosOptions; | ||
response?: RedactableGaxiosResponse<T>; | ||
}; |
@@ -19,3 +19,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultErrorRedactor = exports.GaxiosError = exports.GAXIOS_ERROR_SYMBOL = void 0; | ||
exports.GaxiosError = exports.GAXIOS_ERROR_SYMBOL = void 0; | ||
exports.defaultErrorRedactor = defaultErrorRedactor; | ||
const url_1 = require("url"); | ||
@@ -188,3 +189,2 @@ const util_1 = require("./util"); | ||
} | ||
exports.defaultErrorRedactor = defaultErrorRedactor; | ||
//# sourceMappingURL=common.js.map |
@@ -1,3 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Agent } from 'http'; | ||
@@ -4,0 +2,0 @@ import { URL } from 'url'; |
@@ -29,3 +29,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.request = exports.instance = exports.Gaxios = exports.GaxiosError = void 0; | ||
exports.instance = exports.Gaxios = exports.GaxiosError = void 0; | ||
exports.request = request; | ||
const gaxios_1 = require("./gaxios"); | ||
@@ -48,3 +49,2 @@ Object.defineProperty(exports, "Gaxios", { enumerable: true, get: function () { return gaxios_1.Gaxios; } }); | ||
} | ||
exports.request = request; | ||
//# sourceMappingURL=index.js.map |
@@ -15,5 +15,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRetryConfig = void 0; | ||
exports.getRetryConfig = getRetryConfig; | ||
async function getRetryConfig(err) { | ||
var _a; | ||
let config = getConfig(err); | ||
@@ -38,2 +37,14 @@ if (!err || !err.config || (!config && !err.config.retry)) { | ||
: config.noResponseRetries; | ||
config.retryDelayMultiplier = config.retryDelayMultiplier | ||
? config.retryDelayMultiplier | ||
: 2; | ||
config.timeOfFirstRequest = config.timeOfFirstRequest | ||
? config.timeOfFirstRequest | ||
: Date.now(); | ||
config.totalTimeout = config.totalTimeout | ||
? config.totalTimeout | ||
: Number.MAX_SAFE_INTEGER; | ||
config.maxRetryDelay = config.maxRetryDelay | ||
? config.maxRetryDelay | ||
: Number.MAX_SAFE_INTEGER; | ||
// If this wasn't in the list of status codes where we want | ||
@@ -63,7 +74,3 @@ // to automatically retry, return. | ||
} | ||
// Calculate time to wait with exponential backoff. | ||
// If this is the first retry, look for a configured retryDelay. | ||
const retryDelay = config.currentRetryAttempt ? 0 : (_a = config.retryDelay) !== null && _a !== void 0 ? _a : 100; | ||
// Formula: retryDelay + ((2^c - 1 / 2) * 1000) | ||
const delay = retryDelay + ((Math.pow(2, config.currentRetryAttempt) - 1) / 2) * 1000; | ||
const delay = getNextRetryDelay(config); | ||
// We're going to retry! Incremenent the counter. | ||
@@ -85,3 +92,2 @@ err.config.retryConfig.currentRetryAttempt += 1; | ||
} | ||
exports.getRetryConfig = getRetryConfig; | ||
/** | ||
@@ -145,2 +151,21 @@ * Determine based on config if we should retry the request. | ||
} | ||
/** | ||
* Gets the delay to wait before the next retry. | ||
* | ||
* @param {RetryConfig} config The current set of retry options | ||
* @returns {number} the amount of ms to wait before the next retry attempt. | ||
*/ | ||
function getNextRetryDelay(config) { | ||
var _a; | ||
// Calculate time to wait with exponential backoff. | ||
// If this is the first retry, look for a configured retryDelay. | ||
const retryDelay = config.currentRetryAttempt ? 0 : (_a = config.retryDelay) !== null && _a !== void 0 ? _a : 100; | ||
// Formula: retryDelay + ((retryDelayMultiplier^currentRetryAttempt - 1 / 2) * 1000) | ||
const calculatedDelay = retryDelay + | ||
((Math.pow(config.retryDelayMultiplier, config.currentRetryAttempt) - 1) / | ||
2) * | ||
1000; | ||
const maxAllowableDelay = config.totalTimeout - (Date.now() - config.timeOfFirstRequest); | ||
return Math.min(calculatedDelay, maxAllowableDelay, config.maxRetryDelay); | ||
} | ||
//# sourceMappingURL=retry.js.map |
# Changelog | ||
## [6.7.0](https://github.com/googleapis/gaxios/compare/v6.6.0...v6.7.0) (2024-06-27) | ||
### Features | ||
* Add additional retry configuration options ([#634](https://github.com/googleapis/gaxios/issues/634)) ([cb5c833](https://github.com/googleapis/gaxios/commit/cb5c833a9750bf6d0c0f8e27992bb44bd953566c)) | ||
### Bug Fixes | ||
* **deps:** Update dependency uuid to v10 ([#629](https://github.com/googleapis/gaxios/issues/629)) ([6ff684e](https://github.com/googleapis/gaxios/commit/6ff684e6e6e5f4e5e6d270685b2ac0e4d28bc964)) | ||
## [6.6.0](https://github.com/googleapis/gaxios/compare/v6.5.0...v6.6.0) (2024-05-15) | ||
@@ -4,0 +16,0 @@ |
{ | ||
"name": "gaxios", | ||
"version": "6.6.0", | ||
"version": "6.7.0", | ||
"description": "A simple common HTTP client specifically for Google APIs and services.", | ||
@@ -41,3 +41,3 @@ "main": "build/src/index.js", | ||
"@babel/plugin-proposal-private-methods": "^7.18.6", | ||
"@compodoc/compodoc": "1.1.21", | ||
"@compodoc/compodoc": "1.1.19", | ||
"@types/cors": "^2.8.6", | ||
@@ -54,3 +54,3 @@ "@types/express": "^4.16.1", | ||
"@types/tmp": "0.2.6", | ||
"@types/uuid": "^9.0.0", | ||
"@types/uuid": "^10.0.0", | ||
"abort-controller": "^3.0.0", | ||
@@ -74,3 +74,3 @@ "assert": "^2.0.0", | ||
"karma-webpack": "5.0.0", | ||
"linkinator": "^4.0.0", | ||
"linkinator": "^3.0.0", | ||
"mocha": "^8.0.0", | ||
@@ -82,4 +82,4 @@ "multiparty": "^4.2.1", | ||
"null-loader": "^4.0.0", | ||
"puppeteer": "^21.0.0", | ||
"sinon": "^17.0.0", | ||
"puppeteer": "^19.0.0", | ||
"sinon": "^18.0.0", | ||
"stream-browserify": "^3.0.0", | ||
@@ -97,4 +97,4 @@ "tmp": "0.2.3", | ||
"node-fetch": "^2.6.9", | ||
"uuid": "^9.0.1" | ||
"uuid": "^10.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115165
1303
+ Addeduuid@10.0.0(transitive)
- Removeduuid@9.0.1(transitive)
Updateduuid@^10.0.0