Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] Add logs to OpenApp flow #42168

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libs/ActiveClientManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const init: Init = () => {
const isClientTheLeader: IsClientTheLeader = () => {
const lastActiveClient = activeClients.length && activeClients[activeClients.length - 1];

console.debug('[isClientTheLeader]', {lastActiveClient, clientID});

return lastActiveClient === clientID;
};

Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
Log.info('[AuthScreens] Sending OpenApp');
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Network/SequentialQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ function process(): Promise<void> {
function flush() {
// When the queue is paused, return early. This will keep an requests in the queue and they will get flushed again when the queue is unpaused
if (isQueuePaused) {
console.debug('[SequentialQueue] Queue is paused');
return;
}

if (isSequentialQueueRunning || PersistedRequests.getAll().length === 0) {
console.debug('[SequentialQueue] Skipping flush', {isSequentialQueueRunning, numPersistedRequests: PersistedRequests.getAll().length});
return;
}

// ONYXKEYS.PERSISTED_REQUESTS is shared across clients, thus every client/tab will have a copy
// It is very important to only process the queue from leader client otherwise requests will be duplicated.
if (!ActiveClientManager.isClientTheLeader()) {
console.debug('[SequentialQueue] Client is NOT the leader, skipping flush');
return;
}

Expand Down Expand Up @@ -169,15 +172,18 @@ function push(request: OnyxRequest) {

// If we are offline we don't need to trigger the queue to empty as it will happen when we come back online
if (NetworkStore.isOffline()) {
console.debug('[SequentialQueue] Client is offline, skipping flush');
return;
}

// If the queue is running this request will run once it has finished processing the current batch
if (isSequentialQueueRunning) {
console.debug('[SequentialQueue] isSequentialQueueRunning, waiting for current batch to finish before flushing');
isReadyPromise.then(flush);
return;
}

console.debug('[SequentialQueue] Flushing in push()');
flush();
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ function getPolicyParamsForOpenOrReconnect(): Promise<PolicyParamsForOpenOrRecon
resolve({policyIDList: getNonOptimisticPolicyIDs(policies)});
},
});
Log.info('[getPolicyParamsForOpenOrReconnect] isReadyToOpenApp resolved', true, {policyIDListConnectionID: connectionID});
Copy link
Contributor Author

@jasperhuangg jasperhuangg May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure why I'm logging the connectionID, I guess in case we find that the policyIDList promise isn't resolving we can see what's going on with that connection? Don't really know how to check that though, feedback would be greatly appreciated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will help. The connectionIDs would only help you see the connection in the Onyx mapping - which doesn't really do much except hold the callback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put this log above the Onyx.connect() call.

});
});
}
Expand Down Expand Up @@ -254,6 +255,7 @@ function getOnyxDataForOpenOrReconnect(isOpenApp = false): OnyxData {
*/
function openApp() {
getPolicyParamsForOpenOrReconnect().then((policyParams: PolicyParamsForOpenOrReconnect) => {
Log.info('[openApp] getPolicyParamsForOpenOrReconnect resolved: ', true, policyParams);
const params: OpenAppParams = {enablePriorityModeFilter: true, ...policyParams};

API.write(WRITE_COMMANDS.OPEN_APP, params, getOnyxDataForOpenOrReconnect(true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial experience of this bug was that it looked like API.write() did get called, but we end up just stuck in the queue so the request never happens. It feels like maybe some kind of network request is happening that causes the queue to get blocked.

Expand Down
Loading