Simplify concurrent request error handling

pull/21833/head
Luke Barnard 2018-05-02 10:39:15 +01:00
parent 71c1198d12
commit 2dfb3146b0
1 changed files with 3 additions and 9 deletions

View File

@ -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;
} }
/** /**