Simplify concurrent request error handling
parent
71c1198d12
commit
2dfb3146b0
|
@ -56,22 +56,16 @@ async function limitConcurrency(fn) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let result;
|
|
||||||
let error;
|
|
||||||
|
|
||||||
ongoingRequestCount++;
|
ongoingRequestCount++;
|
||||||
try {
|
try {
|
||||||
result = await fn();
|
return await fn();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err;
|
// We explicitly do not handle the error here, but let it propogate.
|
||||||
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
ongoingRequestCount--;
|
ongoingRequestCount--;
|
||||||
checkBacklog();
|
checkBacklog();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) throw error;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue