File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ const ApiError = require('./error');
1313 *
1414 * @param {Function } request - A function that returns a Promise that resolves with a Response object
1515 * @param {object } options
16- * @param {number } [options.retries ] - Number of retries. Defaults to 5
16+ * @param {number } [options.maxRetries ] - Maximum number of retries. Defaults to 5
1717 * @param {number } [options.interval] - Interval between retries in milliseconds. Defaults to 500
1818 * @returns {Promise<Response> } - Resolves with the response object
1919 * @throws {ApiError } If the request failed
2020 */
2121async function withAutomaticRetries ( request , options = { } ) {
22- const retries = options . retries || 5 ;
22+ const maxRetries = options . maxRetries || 5 ;
2323 const interval = options . interval || 500 ;
2424 const jitter = options . jitter || 100 ;
2525
@@ -60,14 +60,14 @@ async function withAutomaticRetries(request, options = {}) {
6060 }
6161 }
6262
63- if ( Number . isInteger ( retries ) && retries > 0 ) {
63+ if ( Number . isInteger ( maxRetries ) && maxRetries > 0 ) {
6464 if ( Number . isInteger ( delay ) && delay > 0 ) {
65- await sleep ( interval * 2 ** ( options . retries - retries ) ) ;
65+ await sleep ( interval * 2 ** ( options . maxRetries - maxRetries ) ) ;
6666 }
6767 attempts += 1 ;
6868 }
6969 /* eslint-enable no-await-in-loop */
70- } while ( attempts < retries ) ;
70+ } while ( attempts < maxRetries ) ;
7171
7272 return request ( ) ;
7373}
You can’t perform that action at this time.
0 commit comments