You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
networkRequestQueue = [...networkRequestQueue, ...persistedRequests];
We don't need to append networkRequestQueue to itself, if the network is offline, persistedRequests will have all requests we need.
@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.
That's one way to do it
I think it might be simpler to move it to the next thick like so
functionLog(parameters){constcommandName='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 returnPromise.resolve().then(()=>Network.post(commandName,{...parameters,forceNetworkRequest: true}));}
this would add the request to the next queue
For this to happen again we would need to add code that does a Network.post() from inside processNetworkRequestQueue(). I'm not sure why we'd expect this to happen again. This feels like a cut and dried 🐛 to me.
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
catching a change like this in a review is not very easy - we already failed once
while the bug is not produced immediately but once enough logs are accumulated which again makes it hard to discover
Yeah that could work, also feels like a setTimeout() workaround. We need a note to explain why we are pushing things off to the next tick so maybe we can find a better way.
Granted, there might never be another case where we want to avoid triggering a network request immediately with a shouldSendImmediately: false param, but feels like an approachable concept.
catching a change like this in a review is not very easy - we already failed once
while the bug is not produced immediately but once enough logs are accumulated which again makes it hard to discover
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 processsNetworkRequest() to be called if it is running at all (I doubt we'd ever think about this problem again if we do this - famous last words 😅).
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.
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!
Activity
MelvinBot commentedon Jul 24, 2021
Triggered auto assignment to @thienlnam (
Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.MelvinBot commentedon Jul 26, 2021
Triggered auto assignment to @JmillsExpensify (
External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.JmillsExpensify commentedon Jul 28, 2021
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!
Santhosh-Sellavel commentedon Jul 28, 2021
Proposal
The issue happens when the network is offline, retryableRequests are set in ONYX, but not cleared from networkRequestQueue(current queue)
App/src/libs/Network.js
Lines 105 to 117 in ad77386
After updating in the ONYX, here queue gets duplicated,
App/src/libs/Network.js
Lines 32 to 45 in ad77386
networkRequestQueue = [...networkRequestQueue, ...persistedRequests];We don't need to append networkRequestQueue to itself, if the network is offline,
persistedRequestswill have all requests we need.This line should be revisited,
App/src/libs/Network.js
Line 35 in ad77386
didLoadPersistedRequestsif it gets true once, no more requests will get appended.parasharrajat commentedon Jul 28, 2021
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.
thienlnam commentedon Jul 29, 2021
@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.
69 remaining items
kidroca commentedon Oct 25, 2021
That's one way to do it
I think it might be simpler to move it to the next thick like so
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
marcaaron commentedon Oct 25, 2021
Yeah that could work, also feels like a
setTimeout()workaround. We need a note to explain why we are pushing things off to the next tick so maybe we can find a better way.Granted, there might never be another case where we want to avoid triggering a network request immediately with a
shouldSendImmediately: falseparam, but feels like an approachable concept.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
processsNetworkRequest()to be called if it is running at all (I doubt we'd ever think about this problem again if we do this - famous last words 😅).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.
kidroca commentedon Oct 25, 2021
Good stuff,
Now that I took another look I realized this is in the
postmethod and it's simpler and clearer 👍The
isProcessingidea looks good too...mallenexpensify commentedon Oct 27, 2021
@marcaaron , tbc.... once this PR is deployed to production, there shouldn't be double messages any more? If so.. 🎉 🎉 🎉 🎉 🎉
marcaaron commentedon Oct 27, 2021
That is the hope! We will have to wait and see.
kavimuru commentedon Nov 16, 2021
@marcaaron @isagoico
Issue was able to reproduce on the regression round for 1.1.15-1. So reopening the issue.
Bug5330310_Sent_message.mp4
.
MelvinBot commentedon Nov 19, 2021
@marcaaron Whoops! This issue is 2 days overdue. Let's get this updated quick!
marcaaron commentedon Nov 22, 2021
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!