From c6fd321cafb0695a9a4fb2cefefffe8a576b2eef Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Thu, 27 Feb 2025 15:37:33 -0500 Subject: [PATCH] Avoid spurious error log when waiting for contact syncs --- ts/background.ts | 4 ++-- ts/textsecure/syncRequests.ts | 8 +------- ts/util/createIPCEvents.ts | 5 ++++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index 0cfb2cf1ba..6118e01e8b 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1726,9 +1726,9 @@ export async function startApp(): Promise { log.info(`${logId}: postRegistrationSyncs not complete, sending sync`); setIsInitialContactSync(true); - const syncRequest = await sendSyncRequests(); + contactSyncComplete = waitForEvent('contactSync:complete'); + drop(sendSyncRequests()); hasSentSyncRequests = true; - contactSyncComplete = syncRequest.contactSyncComplete; } // 4. Download (or resume download) of link & sync backup diff --git a/ts/textsecure/syncRequests.ts b/ts/textsecure/syncRequests.ts index 3475692d7e..ba56b04395 100644 --- a/ts/textsecure/syncRequests.ts +++ b/ts/textsecure/syncRequests.ts @@ -1,17 +1,12 @@ // Copyright 2025 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -import { waitForEvent } from '../shims/events'; import * as log from '../logging/log'; import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue'; import MessageSender from './SendMessage'; import { toLogFormat } from '../types/errors'; -export async function sendSyncRequests( - timeout?: number -): Promise<{ contactSyncComplete: Promise }> { - const contactSyncComplete = waitForEvent('contactSync:complete', timeout); - +export async function sendSyncRequests(): Promise { log.info('sendSyncRequests: sending sync requests'); try { await Promise.all([ @@ -28,5 +23,4 @@ export async function sendSyncRequests( ); throw error; } - return { contactSyncComplete }; } diff --git a/ts/util/createIPCEvents.ts b/ts/util/createIPCEvents.ts index 1a6f451c05..2f94ea2df7 100644 --- a/ts/util/createIPCEvents.ts +++ b/ts/util/createIPCEvents.ts @@ -54,6 +54,7 @@ import type { import type { SystemTraySetting } from '../types/SystemTraySetting'; import { drop } from './drop'; import { sendSyncRequests } from '../textsecure/syncRequests'; +import { waitForEvent } from '../shims/events'; type SentMediaQualityType = 'standard' | 'high'; type NotificationSettingType = 'message' | 'name' | 'count' | 'off'; @@ -490,9 +491,11 @@ export function createIPCEvents( isPrimary: () => window.textsecure.storage.user.getDeviceId() === 1, syncRequest: async () => { - const { contactSyncComplete } = await sendSyncRequests( + const contactSyncComplete = waitForEvent( + 'contactSync:complete', 5 * durations.MINUTE ); + await sendSyncRequests(); return contactSyncComplete; }, getLastSyncTime: () => window.storage.get('synced_at'),