From d54033d3d44b805a83b872ca20e1d689e0ac9093 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 31 Oct 2024 08:02:32 -0700 Subject: [PATCH 1/2] Log why request is removed from queue --- src/libs/Network/SequentialQueue.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index 35c7b2bf779a..e8e38de1878a 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -96,6 +96,7 @@ function process(): Promise { pause(); } + Log.info('[SequentialQueue] Removing persisted request because it was processed successfully.', false, {request: requestToProcess}); PersistedRequests.remove(requestToProcess); RequestThrottle.clear(); return process(); @@ -104,6 +105,7 @@ function process(): Promise { // On sign out we cancel any in flight requests from the user. Since that user is no longer signed in their requests should not be retried. // Duplicate records don't need to be retried as they just mean the record already exists on the server if (error.name === CONST.ERROR.REQUEST_CANCELLED || error.message === CONST.ERROR.DUPLICATE_RECORD) { + Log.info("[SequentialQueue] Removing persisted request because it failed and doesn't need to be retried.", false, {error, request: requestToProcess}); PersistedRequests.remove(requestToProcess); RequestThrottle.clear(); return process(); @@ -113,6 +115,7 @@ function process(): Promise { .then(process) .catch(() => { Onyx.update(requestToProcess.failureData ?? []); + Log.info('[SequentialQueue] Removing persisted request because it failed too many times.', false, {error, request: requestToProcess}); PersistedRequests.remove(requestToProcess); RequestThrottle.clear(); return process(); From d3e97cd935205fe3ade4f79b5dfe22e424079f33 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 31 Oct 2024 08:12:44 -0700 Subject: [PATCH 2/2] Log when persisted request default to empty to see if it gets queue stuck --- src/libs/actions/PersistedRequests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/actions/PersistedRequests.ts b/src/libs/actions/PersistedRequests.ts index fc14e8c2303b..495e49f6f875 100644 --- a/src/libs/actions/PersistedRequests.ts +++ b/src/libs/actions/PersistedRequests.ts @@ -10,6 +10,7 @@ let ongoingRequest: Request | null = null; Onyx.connect({ key: ONYXKEYS.PERSISTED_REQUESTS, callback: (val) => { + Log.info('[PersistedRequests] hit Onyx connect callback', false, {isValNullish: val == null}); persistedRequests = val ?? []; if (ongoingRequest && persistedRequests.length > 0) { @@ -78,12 +79,15 @@ function remove(requestToRemove: Request) { function update(oldRequestIndex: number, newRequest: Request) { const requests = [...persistedRequests]; + const oldRequest = requests.at(oldRequestIndex); + Log.info('[PersistedRequests] Updating a request', false, {oldRequest, newRequest, oldRequestIndex}); requests.splice(oldRequestIndex, 1, newRequest); persistedRequests = requests; Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, requests); } function updateOngoingRequest(newRequest: Request) { + Log.info('[PersistedRequests] Updating the ongoing request', false, {ongoingRequest, newRequest}); ongoingRequest = newRequest; if (newRequest.persistWhenOngoing) {