Bug fix (forEech and promises...)

This commit is contained in:
Eric van der Vlist 2023-02-12 14:41:19 +01:00
parent 4502162a36
commit 8a63cc07f4
1 changed files with 14 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export { state };
export const watchDbLegacy = async () => {
createRoot(async (dispose) => {
console.log({ caller: 'watchDbLegacy' });
console.log({ caller: 'watchDbLegacy / start' });
db = globalThis.db;
localDb = globalThis.localDb;
@ -189,9 +189,9 @@ export const watchDbLegacy = async () => {
deletedDocs,
state: state(),
});
deletedDocs.forEach(async (doc) => {
await sleep(500);
let i = 0;
for (const doc of deletedDocs) {
await sleep(50);
try {
await db.purge(doc.id, doc.rev);
} catch (err) {
@ -201,7 +201,16 @@ export const watchDbLegacy = async () => {
err,
});
}
});
i = i + 1;
if (i % 10 === 0) {
console.log({
caller: 'watchDbLegacy / purge',
nbDeletedDocs: i,
nbDocsToDelete: deletedDocs.length,
doc,
});
}
}
}
await sleep(60000);
}