From 19059f0e198f4810162bc0bf3763fa4b5337cc3b Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Tue, 17 Dec 2024 05:30:45 +0700 Subject: [PATCH] fix: adjust sync probability and enable requestSync in DocumentSchema - Reduced the background sync probability from 0.1% to 0.01% to minimize unnecessary sync attempts. - Enabled the requestSync flag in the payload to ensure synchronization requests are properly handled. These changes aim to optimize the background synchronization process within the DocumentSchema, enhancing performance and control over sync operations. --- src/Document/document.schema.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Document/document.schema.ts b/src/Document/document.schema.ts index 0bed9eb..f6f568e 100644 --- a/src/Document/document.schema.ts +++ b/src/Document/document.schema.ts @@ -750,7 +750,7 @@ export class DocumentSchema extends PothosSchema { } // Only perform background check with a very low probability - const SYNC_PROBABILITY = 0.01; // 0.1% chance + const SYNC_PROBABILITY = 0.001; // 0.1% chance const SYNC_INTERVAL_MS = 15000; // 15 seconds minimum between syncs const syncKey = `document:sync:${payload.documentId}:${payload.pageIndex}`; @@ -775,6 +775,8 @@ export class DocumentSchema extends PothosSchema { // ctx // ); } + + payload.requestSync = true; // biome-ignore lint/suspicious/noExplicitAny: error is any } catch (error: any) { Logger.error("Background sync check failed", {