From 6c617de892ce57ba891960afbfe9b661ab7ff86b Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 10 Sep 2024 13:46:15 +1000 Subject: [PATCH] fix: clearInbox request timeout after 10s --- .../open_group_api/sogsv3/sogsV3ClearInbox.ts | 18 ++++++++++++------ ts/session/apis/snode_api/SNodeAPI.ts | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ts/session/apis/open_group_api/sogsv3/sogsV3ClearInbox.ts b/ts/session/apis/open_group_api/sogsv3/sogsV3ClearInbox.ts index d7a8b4fa9..e4e213179 100644 --- a/ts/session/apis/open_group_api/sogsv3/sogsV3ClearInbox.ts +++ b/ts/session/apis/open_group_api/sogsv3/sogsV3ClearInbox.ts @@ -8,6 +8,7 @@ import { sogsBatchSend, } from './sogsV3BatchPoll'; import { OpenGroupRequestCommonType } from '../../../../data/types'; +import { PromiseUtils } from '../../../utils'; type OpenGroupClearInboxResponse = { deleted: number; @@ -31,12 +32,17 @@ export const clearInbox = async (roomInfos: OpenGroupRequestCommonType): Promise }, ]; - const result = await sogsBatchSend( - roomInfos.serverUrl, - new Set([roomInfos.roomId]), - new AbortController().signal, - options, - 'batch' + const abortSignal = new AbortController(); + + const result = await PromiseUtils.timeout( + sogsBatchSend( + roomInfos.serverUrl, + new Set([roomInfos.roomId]), + abortSignal.signal, + options, + 'batch' + ), + 10000 ); if (!result) { diff --git a/ts/session/apis/snode_api/SNodeAPI.ts b/ts/session/apis/snode_api/SNodeAPI.ts index 64b15d356..37a508cbf 100644 --- a/ts/session/apis/snode_api/SNodeAPI.ts +++ b/ts/session/apis/snode_api/SNodeAPI.ts @@ -150,7 +150,7 @@ const forceNetworkDeletion = async (): Promise | null> => { } }, { - retries: 3, + retries: 1, minTimeout: SnodeAPI.TEST_getMinTimeout(), onFailedAttempt: e => { window?.log?.warn(