File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -355,21 +355,24 @@ export default class Helpers {
355
355
let loadedOperations = 0
356
356
timeoutRef = setTimeout ( onFlushTimeout , flushInterval ) // eslint-disable-line
357
357
358
- for await ( const operation of operationsStream ) {
359
- timeoutRef . refresh ( )
360
- loadedOperations += 1
361
- msearchBody . push ( operation [ 0 ] , operation [ 1 ] )
362
- callbacks . push ( operation [ 2 ] )
363
- if ( loadedOperations >= operations ) {
364
- const send = await semaphore ( )
365
- send ( msearchBody . slice ( ) , callbacks . slice ( ) )
366
- msearchBody . length = 0
367
- callbacks . length = 0
368
- loadedOperations = 0
358
+ try {
359
+ for await ( const operation of operationsStream ) {
360
+ timeoutRef . refresh ( )
361
+ loadedOperations += 1
362
+ msearchBody . push ( operation [ 0 ] , operation [ 1 ] )
363
+ callbacks . push ( operation [ 2 ] )
364
+ if ( loadedOperations >= operations ) {
365
+ const send = await semaphore ( )
366
+ send ( msearchBody . slice ( ) , callbacks . slice ( ) )
367
+ msearchBody . length = 0
368
+ callbacks . length = 0
369
+ loadedOperations = 0
370
+ }
369
371
}
372
+ } finally {
373
+ clearTimeout ( timeoutRef )
370
374
}
371
375
372
- clearTimeout ( timeoutRef )
373
376
// In some cases the previos http call does not have finished,
374
377
// or we didn't reach the flush bytes threshold, so we force one last operation.
375
378
if ( loadedOperations > 0 ) {
You can’t perform that action at this time.
0 commit comments