Skip to content

Commit 5de0ee3

Browse files
committed
Network retry count for Parallel request
1 parent a00bf43 commit 5de0ee3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/core/contentstack-retry.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
export default function contentstckRetry (axios, defaultOptions, retryLimit = 5, retryDelay = 300) {
33
var networkError = 0
44
axios.interceptors.request.use(function (config) {
5+
config.retryCount = config.retryCount || 0
56
if (config.headers.authorization && config.headers.authorization !== undefined) {
67
delete config.headers.authtoken
78
}
89
return config
910
})
1011

1112
axios.interceptors.response.use(function (response) {
12-
networkError = 0
13+
// networkError = 0
1314
return response
1415
}, function (error) {
1516
var wait = retryDelay
1617
let retryErrorType = null
1718
var response = error.response
18-
19+
networkError = error.config.retryCount
1920
if (!response) {
2021
if (error.code === 'ECONNABORTED') {
2122
error.response = {
@@ -55,6 +56,8 @@ export default function contentstckRetry (axios, defaultOptions, retryLimit = 5,
5556
networkError = 0
5657
}
5758

59+
error.config.retryCount = networkError
60+
5861
if (retryErrorType && error.config !== undefined) {
5962
var config = error.config
6063
defaultOptions.logHandler('warning', `${retryErrorType} error occurred. Waiting for ${wait} ms before retrying...`)

0 commit comments

Comments
 (0)