Skip to content

Commit db259d2

Browse files
committed
fix: infinite loop
1 parent f16d2e0 commit db259d2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/services/ResourceService.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,18 +520,16 @@ async function searchESWithScroll (mustQuery) {
520520
console.log(`totalHits: ${totalHits}`)
521521
// eslint-disable-next-line camelcase
522522
let scrollId = _scroll_id
523-
let currentHits = hits.hits
524523

525-
while (currentHits.length < totalHits) {
526-
console.log(`currentHits.length: ${currentHits.length}`)
524+
while (hits.hits.length < totalHits) {
525+
console.log(`currentHits.length: ${hits.hits.length}`)
527526
const nextScrollResponse = await esClient.scroll({
528527
scroll: scrollTimeout,
529528
scroll_id: scrollId
530529
})
531530

532531
scrollId = nextScrollResponse._scroll_id
533-
currentHits = nextScrollResponse.hits.hits
534-
hits.hits = [...hits.hits, ...currentHits]
532+
hits.hits = [...hits.hits, ...nextScrollResponse.hits.hits]
535533
}
536534

537535
await esClient.clearScroll({

0 commit comments

Comments
 (0)