Skip to content

Commit 74641bb

Browse files
committed
Revert "Improve .retry() method functionality with delays and prevent calling on successful request (#1527)"
This reverts commit 62eae78.
1 parent 0c4f96f commit 74641bb

File tree

9 files changed

+54
-71
lines changed

9 files changed

+54
-71
lines changed

.dist.babelrc

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
}
77
}]
88
],
9-
"plugins": [
10-
["@babel/plugin-transform-runtime"]
11-
]
9+
"sourceMaps": "inline"
1210
}

.dist.eslintrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"no-useless-escape": "off",
1919
"no-cond-assign": "off",
2020
"no-redeclare": "off",
21-
"no-fallthrough": "off",
22-
"no-constant-condition": "off"
21+
"node/no-exports-assign": "off"
2322
},
2423
"globals": {
2524
"regeneratorRuntime": "writable"

.lib.babelrc

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
}
88
}]
99
],
10-
"plugins": [
11-
["@babel/plugin-transform-runtime"]
12-
]
10+
"sourceMaps": "inline"
1311
}

docs/index.md

-9
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,6 @@ This method has two optional arguments: number of retries (default 1) and a call
246246
.then(finished);
247247
.catch(failed);
248248

249-
The callback supplied can be async if you need to await any data or to create a delay before retrying. This code will retry 10 times, with a 3 second delay between each retry. To add a delay:
250-
251-
.retry(10, async function(err, res) {
252-
let delay = 3000; // ms
253-
log.error(`Request failed, retrying in ${delay / 1000} seconds ...`);
254-
await new Promise(resolve => setTimeout(() => resolve(), delay));
255-
return true;
256-
})
257-
258249
Use `.retry()` only with requests that are *idempotent* (i.e. multiple requests reaching the server won't cause undesirable side effects like duplicate purchases).
259250

260251
## Setting Accept

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"Nick Baugh <[email protected]>"
2424
],
2525
"dependencies": {
26-
"@babel/runtime": "7.4.5",
2726
"component-emitter": "^1.3.0",
2827
"cookiejar": "^2.1.2",
2928
"debug": "^4.1.1",

src/client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ Request.prototype._getFormData = function() {
646646
* @api private
647647
*/
648648

649-
Request.prototype.callback = async function(err, res) {
650-
if (err !== null && (await this._shouldRetry(err, res))) {
649+
Request.prototype.callback = function(err, res) {
650+
if (this._shouldRetry(err, res)) {
651651
return this._retry();
652652
}
653653

src/node/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@ Request.prototype.request = function() {
857857
* @api private
858858
*/
859859

860-
Request.prototype.callback = async function(err, res) {
861-
if (err !== null && (await this._shouldRetry(err, res))) {
860+
Request.prototype.callback = function(err, res) {
861+
if (this._shouldRetry(err, res)) {
862862
return this._retry();
863863
}
864864

src/request-base.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ const ERROR_CODES = ['ECONNRESET', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT'];
178178
* @param {Response} [res] response
179179
* @returns {Boolean} if segment should be retried
180180
*/
181-
RequestBase.prototype._shouldRetry = async function(err, res) {
181+
RequestBase.prototype._shouldRetry = function(err, res) {
182182
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
183183
return false;
184184
}
185185

186186
if (this._retryCallback) {
187187
try {
188-
const override = await this._retryCallback(err, res);
188+
const override = this._retryCallback(err, res);
189189
if (override === true) return true;
190190
if (override === false) return false;
191191
// undefined falls back to defaults

yarn.lock

+45-47
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,6 @@
773773
"@babel/types" "^7.4.4"
774774
esutils "^2.0.2"
775775

776-
777-
version "7.4.5"
778-
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
779-
integrity sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==
780-
dependencies:
781-
regenerator-runtime "^0.13.2"
782-
783776
"@babel/runtime@^7.8.4", "@babel/runtime@^7.9.6":
784777
version "7.10.5"
785778
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.5.tgz#303d8bd440ecd5a491eae6117fd3367698674c5c"
@@ -1047,9 +1040,9 @@
10471040
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
10481041

10491042
"@types/node@*":
1050-
version "14.0.23"
1051-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.23.tgz#676fa0883450ed9da0bb24156213636290892806"
1052-
integrity sha512-Z4U8yDAl5TFkmYsZdFPdjeMa57NOvnaf1tljHzhouaPEp7LCj2JKkejpI1ODviIAQuW4CcQmxkQ77rnLsOOoKw==
1043+
version "14.0.26"
1044+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.26.tgz#22a3b8a46510da8944b67bfc27df02c34a35331c"
1045+
integrity sha512-W+fpe5s91FBGE0pEa0lnqGLL4USgpLgs4nokw16SrBBco/gQxuua7KnArSEOd5iaMqbbSHV10vUDkJYJJqpXKA==
10531046

10541047
"@types/normalize-package-data@^2.4.0":
10551048
version "2.4.0"
@@ -2235,14 +2228,14 @@ camelcase@^6.0.0:
22352228
integrity sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==
22362229

22372230
caniuse-db@^1.0.30001090:
2238-
version "1.0.30001102"
2239-
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30001102.tgz#28e7da3f2969781728a0f50119a7aca179bf9e72"
2240-
integrity sha512-VUH/Ch7IaLSmugVKMTQEJlvSUAezLQY0uo1OZ6TJryWDln5vt/QrJjj+h/fVTuhUfYFc4pqfIc0u9ENn+vUy/g==
2231+
version "1.0.30001105"
2232+
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30001105.tgz#5cc03239a9d4540b3fa9a1dc8b5e3bda50226e96"
2233+
integrity sha512-GZytZn8lOiru/Tw+/X5sFxrFt2uPdSvkxVKzRMJyX20JGwfwOuTiRg5IMVF9II8Lao/7C4YeHR8YnZzpTvYXdQ==
22412234

22422235
caniuse-lite@^1.0.30001093:
2243-
version "1.0.30001102"
2244-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001102.tgz#3275e7a8d09548f955f665e532df88de0b63741a"
2245-
integrity sha512-fOjqRmHjRXv1H1YD6QVLb96iKqnu17TjcLSaX64TwhGYed0P1E1CCWZ9OujbbK4Z/7zax7zAzvQidzdtjx8RcA==
2236+
version "1.0.30001105"
2237+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001105.tgz#d2cb0b31e5cf2f3ce845033b61c5c01566549abf"
2238+
integrity sha512-JupOe6+dGMr7E20siZHIZQwYqrllxotAhiaej96y6x00b/48rPt42o+SzOSCPbrpsDWvRja40Hwrj0g0q6LZJg==
22462239

22472240
caseless@~0.6.0:
22482241
version "0.6.0"
@@ -2454,9 +2447,9 @@ [email protected]:
24542447
integrity sha1-TqVOpaCJOBUxheFSEMaNkJK8G3g=
24552448

24562449
codecov@^3.7.0:
2457-
version "3.7.1"
2458-
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202"
2459-
integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw==
2450+
version "3.7.2"
2451+
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.2.tgz#998e68c8c1ef4b55cfcf11cd456866d35e13d693"
2452+
integrity sha512-fmCjAkTese29DUX3GMIi4EaKGflHa4K51EoMc29g8fBHawdk/+KEq5CWOeXLdd9+AT7o1wO4DIpp/Z1KCqCz1g==
24602453
dependencies:
24612454
argv "0.0.2"
24622455
ignore-walk "3.0.3"
@@ -3334,9 +3327,9 @@ [email protected]:
33343327
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
33353328

33363329
electron-to-chromium@^1.3.488:
3337-
version "1.3.499"
3338-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.499.tgz#06949f19877dafa42915e57dfeb4c1cfb86a8649"
3339-
integrity sha512-y7FwtQm/8xuLMnYQfBQDYzCpNn+VkSnf4c3Km5TWMNXg7JA5RQBuxmcLaKdDVcIK0K5xGIa7TlxpRt4BdNxNoA==
3330+
version "1.3.509"
3331+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.509.tgz#830fcb89cd66dc2984d18d794973b99e3f00584c"
3332+
integrity sha512-cN4lkjNRuTG8rtAqTOVgwpecEC2kbKA04PG6YijcKGHK/kD0xLjiqExcAOmLUwtXZRF8cBeam2I0VZcih919Ug==
33403333

33413334
elliptic@^6.0.0, elliptic@^6.5.2:
33423335
version "6.5.3"
@@ -3767,9 +3760,9 @@ eslint-plugin-unicorn@^12.0.0:
37673760
semver "^6.3.0"
37683761

37693762
eslint-rule-docs@^1.1.5:
3770-
version "1.1.199"
3771-
resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.199.tgz#f4e0befb6907101399624964ce4726f684415630"
3772-
integrity sha512-0jXhQ2JLavUsV/8HVFrBSHL4EM17cl0veZHAVcF1HOEoPdrr09huADK9/L7CbsqP4tMJy9FG23neUEDH8W/Mmg==
3763+
version "1.1.200"
3764+
resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.200.tgz#6de559326ff08f87d319f86daee0b26430150f19"
3765+
integrity sha512-3j5+8OVAWepxOZuLijXhqzWFPzD02CqxAP0hnHj1+s6PgTFmSmpaAtwPfv6BZg8NHGxLVS3AD0MIXJIwfn5ypQ==
37733766

37743767
eslint-scope@^5.0.0:
37753768
version "5.1.0"
@@ -5284,17 +5277,17 @@ inline-source-map@~0.6.0:
52845277
source-map "~0.5.3"
52855278

52865279
inquirer@^7.0.0:
5287-
version "7.3.2"
5288-
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.2.tgz#25245d2e32dc9f33dbe26eeaada231daa66e9c7c"
5289-
integrity sha512-DF4osh1FM6l0RJc5YWYhSDB6TawiBRlbV9Cox8MWlidU218Tb7fm3lQTULyUJDfJ0tjbzl0W4q651mrCCEM55w==
5280+
version "7.3.3"
5281+
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
5282+
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
52905283
dependencies:
52915284
ansi-escapes "^4.2.1"
52925285
chalk "^4.1.0"
52935286
cli-cursor "^3.1.0"
52945287
cli-width "^3.0.0"
52955288
external-editor "^3.0.3"
52965289
figures "^3.0.0"
5297-
lodash "^4.17.16"
5290+
lodash "^4.17.19"
52985291
mute-stream "0.0.8"
52995292
run-async "^2.4.0"
53005293
rxjs "^6.6.0"
@@ -6094,9 +6087,9 @@ lint-staged@^10.2.11:
60946087
stringify-object "^3.3.0"
60956088

60966089
listr2@^2.1.0:
6097-
version "2.2.0"
6098-
resolved "https://registry.yarnpkg.com/listr2/-/listr2-2.2.0.tgz#cb88631258abc578c7fb64e590fe5742f28e4aac"
6099-
integrity sha512-Q8qbd7rgmEwDo1nSyHaWQeztfGsdL6rb4uh7BA+Q80AZiDET5rVntiU1+13mu2ZTDVaBVbvAD1Db11rnu3l9sg==
6090+
version "2.3.3"
6091+
resolved "https://registry.yarnpkg.com/listr2/-/listr2-2.3.3.tgz#ee9f4d95dd325ad1ae89fe7327f2a4f4498224b5"
6092+
integrity sha512-vU2eiFEzUEaDjgwRJ/n8RB79K2cBcaTw1DigIGHnXGp/BEeQqxGwiM8R17Itit5l2ykrrST11kw2l9vSpCbqUQ==
61006093
dependencies:
61016094
chalk "^4.0.0"
61026095
cli-truncate "^2.1.0"
@@ -6370,7 +6363,7 @@ [email protected]:
63706363
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
63716364
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
63726365

6373-
lodash@^4.13.1, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.16, lodash@^4.17.19:
6366+
lodash@^4.13.1, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
63746367
version "4.17.19"
63756368
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
63766369
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
@@ -6607,9 +6600,9 @@ mdast-util-toc@^5.0.0:
66076600
unist-util-visit "^2.0.0"
66086601

66096602
mdn-browser-compat-data@^1.0.28:
6610-
version "1.0.31"
6611-
resolved "https://registry.yarnpkg.com/mdn-browser-compat-data/-/mdn-browser-compat-data-1.0.31.tgz#4bc736252fafcafc182f9dd43b105d6795b9a28e"
6612-
integrity sha512-GVQQYWgoH3jbBaIy8M4hrg34qaNpPedtZvwAjUmkpHq4FXKKCea8Ji5rlS32YJSU9dt7TPvuWWX7Cce5mZyFPA==
6603+
version "1.0.32"
6604+
resolved "https://registry.yarnpkg.com/mdn-browser-compat-data/-/mdn-browser-compat-data-1.0.32.tgz#05bdf6b8d49c55a5a2a1c370b68e169300abf56d"
6605+
integrity sha512-dqIstpk2ysqa6XcI8/fz1yB6bOKrIs61RIEE00Dj7+WHReXlGrCIiol1NBPsLUNE+HC/4y2f8va8vy1WsiCkAQ==
66136606
dependencies:
66146607
extend "3.0.2"
66156608

@@ -7200,9 +7193,9 @@ node-preload@^0.2.1:
72007193
process-on-spawn "^1.0.0"
72017194

72027195
node-releases@^1.1.58:
7203-
version "1.1.59"
7204-
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.59.tgz#4d648330641cec704bff10f8e4fe28e453ab8e8e"
7205-
integrity sha512-H3JrdUczbdiwxN5FuJPyCHnGHIFqQ0wWxo+9j1kAXAzqNMAHlo+4I/sYYxpyK0irQ73HgdiyzD32oqQDcU2Osw==
7196+
version "1.1.60"
7197+
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.60.tgz#6948bdfce8286f0b5d0e5a88e8384e954dfe7084"
7198+
integrity sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA==
72067199

72077200
node-uuid@~1.4.0, node-uuid@~1.4.1:
72087201
version "1.4.8"
@@ -7676,9 +7669,9 @@ parse-json@^4.0.0:
76767669
json-parse-better-errors "^1.0.1"
76777670

76787671
parse-json@^5.0.0:
7679-
version "5.0.0"
7680-
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.0.0.tgz#73e5114c986d143efa3712d4ea24db9a4266f60f"
7681-
integrity sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==
7672+
version "5.0.1"
7673+
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.0.1.tgz#7cfe35c1ccd641bce3981467e6c2ece61b3b3878"
7674+
integrity sha512-ztoZ4/DYeXQq4E21v169sC8qWINGpcosGv9XhTDvg9/hWvx/zrFkc9BiWxR58OJLHGk28j5BL0SDLeV2WmFZlQ==
76827675
dependencies:
76837676
"@babel/code-frame" "^7.0.0"
76847677
error-ex "^1.3.1"
@@ -8279,11 +8272,16 @@ regenerate@^1.4.0:
82798272
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.1.tgz#cad92ad8e6b591773485fbe05a485caf4f457e6f"
82808273
integrity sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A==
82818274

8282-
[email protected], regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.4:
8275+
82838276
version "0.13.5"
82848277
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
82858278
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==
82868279

8280+
regenerator-runtime@^0.13.4:
8281+
version "0.13.7"
8282+
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
8283+
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
8284+
82878285
regenerator-transform@^0.14.2:
82888286
version "0.14.5"
82898287
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4"
@@ -8416,7 +8414,7 @@ remark-heading-gap@^3.1.2:
84168414
resolved "https://registry.yarnpkg.com/remark-heading-gap/-/remark-heading-gap-3.1.2.tgz#480b71a655e793848db42b714358b5533d7d5ec3"
84178415
integrity sha512-LNm1B4UveH1BkSLx4OPab0vW/p3KOc+8wV4kd94CHXmhuJ8i+kdroG2AonkUVzbOElc8U8ylxF3WPfmqYbRjJg==
84188416

8419-
remark-license@niftylettuce/remark-license:
8417+
"remark-license@github:niftylettuce/remark-license":
84208418
version "4.0.1"
84218419
resolved "https://codeload.github.com/niftylettuce/remark-license/tar.gz/17ecb8f64f8f6082414d14f9267a12764e6ddbfb"
84228420
dependencies:
@@ -10759,9 +10757,9 @@ unified-message-control@^3.0.0:
1075910757
vfile-location "^3.0.0"
1076010758

1076110759
unified@^9.0.0:
10762-
version "9.0.0"
10763-
resolved "https://registry.yarnpkg.com/unified/-/unified-9.0.0.tgz#12b099f97ee8b36792dbad13d278ee2f696eed1d"
10764-
integrity sha512-ssFo33gljU3PdlWLjNp15Inqb77d6JnJSfyplGJPT/a+fNRNyCBeveBAYJdO5khKdF6WVHa/yYCC7Xl6BDwZUQ==
10760+
version "9.1.0"
10761+
resolved "https://registry.yarnpkg.com/unified/-/unified-9.1.0.tgz#7ba82e5db4740c47a04e688a9ca8335980547410"
10762+
integrity sha512-VXOv7Ic6twsKGJDeZQ2wwPqXs2hM0KNu5Hkg9WgAZbSD1pxhZ7p8swqg583nw1Je2fhwHy6U8aEjiI79x1gvag==
1076510763
dependencies:
1076610764
bail "^1.0.0"
1076710765
extend "^3.0.0"

0 commit comments

Comments
 (0)