aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/requestsScheduler.js28
1 files changed, 13 insertions, 15 deletions
diff --git a/server/lib/requestsScheduler.js b/server/lib/requestsScheduler.js
index 3c1df5d5c..78570209d 100644
--- a/server/lib/requestsScheduler.js
+++ b/server/lib/requestsScheduler.js
@@ -152,7 +152,7 @@ function makeRequests () {
152 } 152 }
153 153
154 // For each requests to make, we add it to the correct request type 154 // For each requests to make, we add it to the correct request type
155 async.each(requests, function (poolRequest, callbackEach) { 155 requests.forEach(function (poolRequest) {
156 if (REQUEST_SCHEDULER_TYPE.indexOf(poolRequest.type) > -1) { 156 if (REQUEST_SCHEDULER_TYPE.indexOf(poolRequest.type) > -1) {
157 const requestTypeToMake = requestsToMake[poolRequest.type] 157 const requestTypeToMake = requestsToMake[poolRequest.type]
158 requestTypeToMake.requests.push(poolRequest.request) 158 requestTypeToMake.requests.push(poolRequest.request)
@@ -161,22 +161,20 @@ function makeRequests () {
161 logger.error('Unkown request type.', { request_type: poolRequest.type }) 161 logger.error('Unkown request type.', { request_type: poolRequest.type })
162 return // abort 162 return // abort
163 } 163 }
164 })
164 165
165 callbackEach() 166 for (let type of Object.keys(requestsToMake)) {
166 }, function () { 167 const requestTypeToMake = requestsToMake[type]
167 for (let type of Object.keys(requestsToMake)) { 168 // If there are requests for this type
168 const requestTypeToMake = requestsToMake[type] 169 if (requestTypeToMake.requests.length !== 0) {
169 // If there are requests for this type 170 makeRequest(type, requestTypeToMake.requests, function (err) {
170 if (requestTypeToMake.requests.length !== 0) { 171 if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err })
171 makeRequest(type, requestTypeToMake.requests, function (err) { 172
172 if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err }) 173 // We made the requests, so we can remove them from the scheduler
173 174 Requests.removeRequests(requestTypeToMake.ids)
174 // We made the requests, so we can remove them from the scheduler 175 })
175 Requests.removeRequests(requestTypeToMake.ids)
176 })
177 }
178 } 176 }
179 }) 177 }
180 }) 178 })
181} 179}
182 180