Bug fix (forEech and promises...)
This commit is contained in:
parent
4502162a36
commit
8a63cc07f4
|
@ -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,8 +201,17 @@ 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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue