Prevents infinite loop if offset gets higher than maxSize

This commit is contained in:
Jesús Ángel 2019-01-09 16:41:05 +01:00
parent 5566f047cd
commit 5a2691642b

View File

@ -27,7 +27,8 @@ export function buildOptionsObject(api) {
export async function fetchAllAgents(api, maxSize, payload, options) { export async function fetchAllAgents(api, maxSize, payload, options) {
try { try {
let agents = []; let agents = [];
while (agents.length < maxSize) { // Prevents infinite loop if offset gets higher than maxSize
while ((agents.length < maxSize) && (payload.offset < maxSize)) {
const response = await needle( const response = await needle(
'get', 'get',
`${getPath(api)}/agents`, `${getPath(api)}/agents`,