@@ -12,11 +12,11 @@ export function ConcurrencyQueue ({ axios, config }) {
12
12
13
13
if ( config ) {
14
14
if ( config . maxRequests && config . maxRequests <= 0 ) {
15
- throw Error ( 'Concurrency Manager Error: minimun concurrent requests is 1' )
15
+ throw Error ( 'Concurrency Manager Error: minimum concurrent requests is 1' )
16
16
} else if ( config . retryLimit && config . retryLimit <= 0 ) {
17
- throw Error ( 'Retry Policy Error: minimun retry limit is 1' )
17
+ throw Error ( 'Retry Policy Error: minimum retry limit is 1' )
18
18
} else if ( config . retryDelay && config . retryDelay < 300 ) {
19
- throw Error ( 'Retry Policy Error: minimun retry delay for requests is 300' )
19
+ throw Error ( 'Retry Policy Error: minimum retry delay for requests is 300' )
20
20
}
21
21
}
22
22
@@ -98,6 +98,9 @@ export function ConcurrencyQueue ({ axios, config }) {
98
98
const delay = ( time ) => {
99
99
if ( ! this . paused ) {
100
100
this . paused = true
101
+ // Check for current running request.
102
+ // Wait for running queue to complete.
103
+ // Wait and prosed the Queued request.
101
104
if ( this . running . length > 0 ) {
102
105
setTimeout ( ( ) => {
103
106
delay ( time )
@@ -121,13 +124,13 @@ export function ConcurrencyQueue ({ axios, config }) {
121
124
122
125
const responseErrorHandler = error => {
123
126
let networkError = error . config . retryCount
127
+ let retryErrorType = null
124
128
if ( ! this . config . retryOnError || networkError > this . config . retryLimit ) {
125
129
return Promise . reject ( responseHandler ( error ) )
126
130
}
127
131
128
132
// Error handling
129
133
let wait = this . config . retryDelay
130
- let retryErrorType = null
131
134
const response = error . response
132
135
if ( ! response ) {
133
136
if ( error . code === 'ECONNABORTED' ) {
@@ -147,8 +150,9 @@ export function ConcurrencyQueue ({ axios, config }) {
147
150
return Promise . reject ( responseHandler ( error ) )
148
151
}
149
152
this . running . shift ( )
153
+ wait = 1000
150
154
// Cooldown the running requests
151
- delay ( 1000 )
155
+ delay ( wait )
152
156
error . config . retryCount = networkError
153
157
154
158
return axios ( updateRequestConfig ( error , retryErrorType , wait ) )
@@ -177,7 +181,6 @@ export function ConcurrencyQueue ({ axios, config }) {
177
181
} , wait )
178
182
} )
179
183
}
180
-
181
184
return Promise . reject ( responseHandler ( error ) )
182
185
}
183
186
0 commit comments