Skip to content

Commit 3cb0940

Browse files
karlriisJoshMock
andcommitted
fix: keep track of indexSlice explicitly in bulk helper response handling loop (#1759)
Co-authored-by: Josh Mock <[email protected]>
1 parent 9c000df commit 3cb0940

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,13 @@ export default class Helpers {
823823
}
824824
const retry = []
825825
const { items } = result
826+
let indexSlice = 0
826827
for (let i = 0, len = items.length; i < len; i++) {
827828
const action = items[i]
828829
const operation = Object.keys(action)[0]
829830
// @ts-expect-error
830831
const responseItem = action[operation as keyof T.BulkResponseItemContainer]
831832
assert(responseItem !== undefined, 'The responseItem is undefined, please file a bug report')
832-
const indexSlice = operation !== 'delete' ? i * 2 : i
833833

834834
if (responseItem.status >= 400) {
835835
// 429 is the only staus code where we might want to retry
@@ -857,6 +857,7 @@ export default class Helpers {
857857
} else {
858858
stats.successful += 1
859859
}
860+
operation === 'delete' ? indexSlice += 1 : indexSlice += 2
860861
}
861862
callback(null, retry)
862863
})

0 commit comments

Comments
 (0)