Fix onFlushTimeout timer not being cleared when upstream errors (#1616)

This commit is contained in:
Rostislav Provodenko
2022-02-24 13:29:20 +03:00
committed by GitHub
parent e7c5b3dafa
commit d01582803c

View File

@ -355,6 +355,7 @@ export default class Helpers {
let loadedOperations = 0
timeoutRef = setTimeout(onFlushTimeout, flushInterval) // eslint-disable-line
try {
for await (const operation of operationsStream) {
timeoutRef.refresh()
loadedOperations += 1
@ -368,8 +369,10 @@ export default class Helpers {
loadedOperations = 0
}
}
} finally {
clearTimeout(timeoutRef)
}
// In some cases the previos http call does not have finished,
// or we didn't reach the flush bytes threshold, so we force one last operation.
if (loadedOperations > 0) {