From 13f5456b39ac834151e1f0851065f6f2efbf81e3 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 27 Nov 2025 22:21:13 +0000 Subject: [PATCH] Fix race condition --- frontend/sync-client/src/sync-operations/syncer.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index 43df0a85..897bdf57 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -412,7 +412,7 @@ export class Syncer { } } - const updates = awaitAll( + await awaitAll( allLocalFiles.map(async (relativePath) => { if ( this.database.getLatestDocumentByRelativePath(relativePath) @@ -470,7 +470,9 @@ export class Syncer { }) ); - const deletes = awaitAll( + // this has to happen strictly after the previous awaitAll, as that one + // might have removed some of the documents from the list + await awaitAll( locallyPossiblyDeletedFiles.map(async ({ relativePath }) => { this.logger.debug( `Document ${relativePath} has been deleted locally, scheduling sync to delete it` @@ -480,8 +482,6 @@ export class Syncer { return this.syncLocallyDeletedFile(relativePath); }) ); - - await awaitAll([updates, deletes]); } /**