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
Forms don't download on slow connections #2134
Comments
It shouldn't cancel a download after 10 seconds if it's managed to actually connect (I hope!). What is more likely is that it's not even managing to connect in those 10 seconds. Regardless, we should be able to change that to something like 30 seconds pretty easily I think. |
That makes sense. Changing it to something higher would help a lot and make it easier to load phones on slower connections. We had to ask everyone in this training to turn off WiFi so that I can update some phones :) |
@sglangevin can you go into a bit more detail about when these timeouts are occurring? Currently it looks like for the initial replication we have a timeout of 30 seconds, and for continuous replication we don't have a timeout at all! Having said that, it's unclear to me which timeout we are talking about in our code, and whether or not those values are also used for individual document requests. |
The 30 second timeout for initial replication isn't long enough. It almost always fails on the WiFi at LG HQ. I've also seen it fail on better connections (WiFi in Nairobi). Haven't tested thoroughly on an SF-speed connection. The easiest way to observe this is to try a clean install on your Tecno on a slow internet connection using developer tools so that you see the network requests and console. I will take some screen shots here as well. |
OK ignore me I've found it. There is a separate timeout that you set specifically for ajax requests. |
Also, just as a note. If initial replication fails, forms are still downloaded during continuous replication. But it only seems to try to download form definitions once, so if it doesn't work the first time you have to clear data and start again. I may also not be understanding what is happening correctly and the forms would come later, but I haven't seen that happen before. |
By default PouchDB has a 10 second timeout for HTTP requests. To improve reliability on bad connections this ups the value to 30 seconds. NB: This is a separate value to the general replication timeout. Issue: #2134
AFAIK forms are just documents like everything else, so I'd hope it would try again. |
Maybe someone can tell me when that would happen - it doesn't seem like reload helps with that and I haven't seen it retry on forms or icons before. But maybe that would happen the next time I re-open the app? I haven't tested thoroughly enough to know but was wondering if anyone can confirm how this is supposed to work. |
I don't think that's the right timeout. That changes the timeout for stuff we request from the remote db which isn't very common. The timeout we need to set is buried deep inside pouch replication. I don't think there's any way currently to change this without patching pouch. |
Yep that was the one I was intent on changing, based on this comment:
So I figure (@sglangevin correct me if I'm wrong) that she meant that she's watching the network tab and Pouch does a GET for a form and then it times out. FWIW I've also seen this before. |
And then 10 seconds later after reading the code you linked… Oh right. Darn. |
So yeah, I've also looked through the code and you're totally right, it's not clear you can actually change this value at all. What is confusing to me is that it's not clear why the replication timeout (what you specify when kicking off a replication) isn't also used in this situation: that would make sense to me. |
Too bad. There are 2 timeouts that are affecting initial replication. One is the timeout for initial replication, which seems to be 30 seconds. Initial replication completes but has status failed, then continuous replication begins and when the series of GET requests go out for forms and icons, if there is no response within 10 seconds, they cancel and forms are never downloaded. The only solution is to clear the app's data, try again, and hope for the best. FWIW I'm also seeing this on slow connections when using the webapp. If you are trying to create a CHP area, there is a person dropdown for CHP and for supervisor. Often, these also timeout as the timeout is still 10 seconds when loading things from the DB into the webapp. From the thread on the other issue, it sounds like Couch 2.0 might help, but I do see this being a consistent problem on slower connections, especially when there are a lot of people in the database. |
Hrm, reading the code, we actually manage to pass down Reports of something failing to download and then never downloading is worrying. I'm wondering if it's a bug in pouch around attachments (we have documents for forms but it's just metadata, the actual form is an attachment on that document), because everything I know about Pouch suggests that if it tries to replicate a document and it fails it should try again until it succeeds, and only then mark that document as replicated. I will try to reproduce it if possible. |
@sglangevin next time you have an instance which doesn't work, could you run the following in the javascript console?
I'm interested to know if the form |
@alxndrsn I ran into this issue again today due to slow network here in NBO. Here is the output from running that code, forms that are definitely missing are contact:clinic:edit, contact:health_center:create, contact:health_center:edit: |
For more detailed output of the forms you have locally, run this: angular.element(document.body).injector().get('DB').get()
.query('medic/doc_by_type', { startkey:['form'], endkey:['form'], include_docs:true, attachments:true })
.then(function(res) {
console.log('RAW RESULT', JSON.stringify(res));
}); |
From @sglangevin, server Local forms:
All of these forms seem to have valid XML, except for Forms on server
NBDoes not updateThis report was originally done 40 minutes ago. No new forms have arrived in the intervening period, despite working internet connection. Deleted formsForms appear client-side which were deleted and no longer appear on the server:
Missing formsThe following are missing client-side:
|
Would be interesting to see a comparison of the XML sizes for the different forms - perhaps the missing ones are really big. |
Forms size comparison:
|
|
@sglangevin reports that restarting the app does not re-trigger the form download - local storage must be wiped and process restarted from scratch. |
Yeah, looks like a pouch regression. seq is updated the same whether or not all docs replicated successfully. |
|
Looks good. |
Related: #2167 |
Requests for form definitions seem to be cancelled after 10 seconds. On slow connections, this isn't enough time to download the form definition. Can we extend this timeout?
The text was updated successfully, but these errors were encountered: