From bd221f27270a56bb6b9d363866dfc3c07a5dfa9a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 22 Dec 2023 11:52:48 +0100 Subject: [PATCH] Prevent locks --- .../server/scripts/load/create-many-relationships.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/server/scripts/load/create-many-relationships.js b/packages/server/scripts/load/create-many-relationships.js index f683d3aed4..07861cc632 100755 --- a/packages/server/scripts/load/create-many-relationships.js +++ b/packages/server/scripts/load/create-many-relationships.js @@ -43,10 +43,13 @@ async function batchCreate(apiKey, appId, table, items, batchSize = 100) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { const item = items[itemIndex] - const promise = createSingleRow(item).then(result => { - rows.push(result) - delete inFlight[itemIndex] - }) + const promise = createSingleRow(item) + .then(result => { + rows.push(result) + }) + .finally(() => { + delete inFlight[itemIndex] + }) inFlight[itemIndex] = promise