-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Network] Messages are sent twice #4214
Comments
Triggered auto assignment to @thienlnam ( |
Triggered auto assignment to @JmillsExpensify ( |
Posted to Upwork here! https://www.upwork.com/jobs/~018c22cb61e93a114c. Make sure to share your technical proposal with us here and a colleague will approve your technical proposal. Thank you! |
ProposalThe issue happens when the network is offline, retryableRequests are set in ONYX, but not cleared from networkRequestQueue(current queue) Lines 105 to 117 in ad77386
After updating in the ONYX, here queue gets duplicated, Lines 32 to 45 in ad77386
This line should be revisited, Line 35 in ad77386
|
We have an existing issue #2451 which solves this problem as well. PR is stalled for that. I will update you here about the PR status. |
@Santhosh-Sellavel Thank you for the great proposal! The changes look good but it seems like @parasharrajat is fixing this in another PR from fixing another bug so I'm just going to have him assigned to this issue as well. |
@parasharrajat you should be rich already 😂. |
Is there anything about logging a comment that is idempotent? This could be another reason to generate random client-side action IDs, such that we can suppress duplicate uploads. /cc @marcaaron @tgolen |
@JmillsExpensify, @parasharrajat, @thienlnam Eep! 4 days overdue now. Issues have feelings too... |
PR is in review. |
@JmillsExpensify, @parasharrajat, @thienlnam it looks like no one is assigned to work on this job. |
I've been OOO. Hired appropriately in Upwork. |
Just so this issue stays focused... I think this is where we last left things. @kidroca can we add this context to a new issue (though it already sounds like we have decided it's not a problem)? @iwiznia maybe you want to comment there on the logging stuff. |
@isagoico @marcaaron |
Sounds good, thanks for this investigation btw - I had a feeling we were missing something right under our noses. Let's see what @quinthar thinks? I'm a bit unsure how to prioritize based on the previous comments. I think at a minimum we should treat these as separate issues so there is not too much overlap in the conversation here. I've labeled this |
Oh wow, yes. I broke hits inadvertently when adding the logging and the fact that logs are not always sent immediately made the issue harder to pinpoint. Great investigation!
I agree with this, otherwise any other code in the future that does what the logging did will again break things. |
Looking at this more though @kidroca has shown we are double processing the networking queue whenever we send a log packet. For this to happen again we would need to add code that does a Anyway, there's an easy solution to the current problem - just send all logs on the "next tick" of the request queue. Lines 256 to 257 in 97f8641
We can just add a param to the request that prevents this call. The log request will be sent on the next call instead. Something like if (!processImmediately) {
return;
}
processNetworkRequestQueue(); |
That's one way to do it function Log(parameters) {
const commandName = 'Log';
requireParameters(['message', 'parameters', 'expensifyCashAppVersion'],
parameters, commandName);
// Note: We are forcing Log to run since it requires no authToken and should only be queued when we are offline.
// We're scheduling the call for the next tick so that we don't re-trigger the network queue
return Promise.resolve()
.then(() => Network.post(commandName, {...parameters, forceNetworkRequest: true}));
}
I agree it's a rare thing, but it happened for Logging and can happen again, people are unaware that their change can produce such effects
|
Yeah that could work, also feels like a Granted, there might never be another case where we want to avoid triggering a network request immediately with a
For what it's worth, I managed to add a failing test for this so we will have some protection if someone decides it would be fun to break the behavior again. There's also another measure we could take here which is to just completely disallow let isProcessing;
function processNetworkQueue() {
if (isProcessing) {
return;
}
// ...process
isProcessing = false;
} as long as the queue does not fail to empty in the "...process" part of the function there is no way for duplicate processing to happen and whatever is trying to happen will run on the next tick. |
Good stuff, if (!processImmediately) {
return;
} The |
@marcaaron , tbc.... once this PR is deployed to production, there shouldn't be double messages any more? If so.. 🎉 🎉 🎉 🎉 🎉 |
That is the hope! We will have to wait and see. |
@marcaaron @isagoico Bug5330310_Sent_message.mp4. |
@marcaaron Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Hmm there may be other causes such as messing with the cell data in this case. I think perhaps we should create a new issue with the exact reproduction steps for that. The issue with Log should be sorted. @kavimuru please open a new issue if you can and document exactly how to reproduce thanks! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
Messages sent with an unstable internet connection should be sent without any issues.
Actual Result:
Messages are sent twice when there's unstable internet connection
Workaround:
Unknown.
Platform:
Where is this issue occurring?
Version Number: 1.0.80-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
View all open jobs on Upwork
From @JmillsExpensify https://expensify.slack.com/archives/C01GTK53T8Q/p1626890348078000
The text was updated successfully, but these errors were encountered: