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