1
0
Fork 0
mirror of synced 2024-07-29 01:56:15 +12:00

Prevent locks

This commit is contained in:
Adria Navarro 2023-12-22 11:52:48 +01:00
parent c5a50a911f
commit bd221f2727

View file

@ -43,10 +43,13 @@ async function batchCreate(apiKey, appId, table, items, batchSize = 100) {
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
const item = items[itemIndex] const item = items[itemIndex]
const promise = createSingleRow(item).then(result => { const promise = createSingleRow(item)
rows.push(result) .then(result => {
delete inFlight[itemIndex] rows.push(result)
}) })
.finally(() => {
delete inFlight[itemIndex]
})
inFlight[itemIndex] = promise inFlight[itemIndex] = promise