@@ -12,11 +12,11 @@ export function ConcurrencyQueue ({ axios, config }) {
1212
1313 if ( config ) {
1414 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' )
1616 } 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' )
1818 } 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' )
2020 }
2121 }
2222
@@ -98,6 +98,9 @@ export function ConcurrencyQueue ({ axios, config }) {
9898 const delay = ( time ) => {
9999 if ( ! this . paused ) {
100100 this . paused = true
101+ // Check for current running request.
102+ // Wait for running queue to complete.
103+ // Wait and prosed the Queued request.
101104 if ( this . running . length > 0 ) {
102105 setTimeout ( ( ) => {
103106 delay ( time )
@@ -121,13 +124,13 @@ export function ConcurrencyQueue ({ axios, config }) {
121124
122125 const responseErrorHandler = error => {
123126 let networkError = error . config . retryCount
127+ let retryErrorType = null
124128 if ( ! this . config . retryOnError || networkError > this . config . retryLimit ) {
125129 return Promise . reject ( responseHandler ( error ) )
126130 }
127131
128132 // Error handling
129133 let wait = this . config . retryDelay
130- let retryErrorType = null
131134 const response = error . response
132135 if ( ! response ) {
133136 if ( error . code === 'ECONNABORTED' ) {
@@ -147,8 +150,9 @@ export function ConcurrencyQueue ({ axios, config }) {
147150 return Promise . reject ( responseHandler ( error ) )
148151 }
149152 this . running . shift ( )
153+ wait = 1000
150154 // Cooldown the running requests
151- delay ( 1000 )
155+ delay ( wait )
152156 error . config . retryCount = networkError
153157
154158 return axios ( updateRequestConfig ( error , retryErrorType , wait ) )
@@ -177,7 +181,6 @@ export function ConcurrencyQueue ({ axios, config }) {
177181 } , wait )
178182 } )
179183 }
180-
181184 return Promise . reject ( responseHandler ( error ) )
182185 }
183186
0 commit comments