Skip to content
Closed
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
3 changes: 3 additions & 0 deletions src/libs/Network/SequentialQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ function unpause() {
const numberOfPersistedRequests = PersistedRequests.getAll().length || 0;
Log.info(`[SequentialQueue] Unpausing the queue and flushing ${numberOfPersistedRequests} requests`);
isQueuePaused = false;
if (numberOfPersistedRequests === 0) {
flushOnyxUpdatesQueue();
}
Comment on lines +199 to +201

@aldo-expensify aldo-expensify Nov 1, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@danieldoglas @tgolen can I have your opinion on this change please. I think you may know more about the possible implications of changing this behaviour in the queue.

You may want to look at here too: #51712 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm. I'm not 100% sure.

Considering that GetMissingOnyxUpdates is not added to the sequential queue, this might call the flush method while GetMissingOnyxUpdates is being executed.

@chrispader what do you think?

@aldo-expensify aldo-expensify Nov 1, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In case it is of interest... another way of fixing the problem we are trying to fix here would be to stop forwarding the CreateReportAction command here: https://github.com/Expensify/Auth/blob/de9f50789e666b56e0bee0e1658b8fa67a35c742/auth/lib/Report.cpp#L7797-L7805 and do it without command forwarding. The command forwarding is causing the OpenReport to not return the correct lastUpdateID. The command forwarding was done to allow OpenReport to finish faster (optimization).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's definitely not idea to make OpenReport slower... but it also definitely sounds like a backend bug and the frontend fix is only a bandaid over it. I especially am concerned that the sequential queue is being changed to try and work around this.

I don't know if this is even possible, or what it would do... but what would happen if we changed OpenReport to not return lastUpdateID at all? I think that would be better than returning an incorrect one.

@chrispader chrispader Nov 2, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Considering that GetMissingOnyxUpdates is not added to the sequential queue

The deferred update logic in OnyxUpdateManager is always only triggered after the SequentialQueue has been paused.

this might call the flush method while GetMissingOnyxUpdates is being executed.

Calling flushOnyxUpdatesQueue() while the SequentialQueue is still paused will result in nothing except for a log.

if (isQueuePaused) {
Log.info('[SequentialQueue] Queue already paused');
return;
}

Therefore i don't think the deferred update logic in OnyxUpdateManager would be affected. Though, this means that the QueuedOnyxUpdates won't actually get flushed if there is a GetMissingOnyxUpdates check currently running

Since we don't introduce an extra SequentialQueue.unpause() call in this PR, i don't see a technical problem about this change.

but ... ⬇️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like Aldo is OOO until Monday. I think this is OK to wait to hear back from him.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@aldo-expensify Do you have any idea what the practical timing measurements are for not forwarding that command on the backend? Does it significantly slow down OpenReport or not?

This optimization was introduced here https://github.com/Expensify/Auth/pull/8595/files for the command CreateChatReport, so it seems like affecting OpenReport was not the intention.

From the conversations in the issue, it looks like the slow part of creating a new chat is checking if the "participants know each other" in this query: https://github.com/Expensify/Auth/blob/01acb32728415564d4ef0321934433bde38c1462/auth/lib/Account.cpp#L4465-L4484

Removing the command forwarding may help with @DylanDylann 's case here since this code is reused by more than one command and it may be root cause of that issue too.

Maybe one thing we can try is: calculate the Account::isAccountKnownToCurrentUser in prePeek (it is the expensive part we want to avoid in process) and revert the command forwarding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe one thing we can try is: calculate the Account::isAccountKnownToCurrentUser in prePeek (it is the expensive part we want to avoid in process) and revert the command forwarding.

I'll start working on a backend PR and assess how feasible this is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

flush();
}

Expand Down