Hi, I have a wix Data Collection that contains around 4000 items which are updated from an external api.
When I am updating these items - I often encounter several different types of errors - most common of which is some form of timeout error (e.g: WDE0028: Request timed out.). Another error I encountered is: WDE0053: Internal wixData error: WDE0055: Failed to parse server response. WD_UNKNOWN_ERROR
(Simplified) Code below:
let dataset = $w("#myDataset");
dataset.onReady(async() => {
let itemIndex = dataset.getCurrentItemIndex();
let item = dataset.getCurrentItem();
while (item) {
aFieldValue = await external_dataApi(item.primaryKey);
if (typeof aFieldValue !== "undefined") {
await dataset.setFieldValue('aField', aFieldValue);
await dataset.save();
} else {
console.log("Value NOT updated for: " + item.primaryKey);
}
item = await dataset.next();
}
});
Any inputs on how to make this stable so wix dataset doesn’t keep giving errors much appreciated, Thanks!
#wixcode #wixdataset #wixdatacollection
Hope someone is monitoring this forum and will respond soon. Thanks.
1 Like
I also have a quite simple website in which users logged into the members area can add entries to database collections, and it fails in around 40% of attempts often with: Error: WDE0028: Request timed out.
I hope someone from wix will answer soon on how to resolve this.
@deleteduser Thank you, unfortunately in my interactions with the support center folks, they seem not very knowledgeable about wix corvid
@deleteduser Thank you for tagging the moderators and hoping at least some one would respond – close to 14 days and still no response.
@tabraham I suspect using a while loop for item is really not the best way to go here. Unless you’ve found a solid reference that I’m wrong, I would play around with a different solution.
Also, async await cannot always work wonders. For something this heavy, some callback function might be the best way. Take for example this callback which runs a loop within a loop with extremely reliability, and with which you would need async await only to call backend/public functions:
let j = 0;
function foo(cloneArray) {
bar(someArray[j], j, () => { j++ }); //increment j is callback
if (j < cloneArray.length) foo(someArray);
}
function bar(arr, index, callback) {
for (let i = 0; i < arr.length; i++) {
//do stuff here
if (i === arr.length - 1) callback();
}
}
@deleteduser many thanks - not sure what that would entail for you – is that a separate wix forum?
Wix support has currently promised to take this up with the ‘advance tech team’ - so hopefully we will get some response from them - let’s see.
Thanks again.
@skmedia thanks – good to hear from you again. I am using this for a non-ui / maintenance functionality ( plus arrow functions give me a headache 
I have seen similar approach in some of the wix documentation for loop across the dataset using the while loop as above.
@deleteduser many thanks.
Such updates are usually more reliably done in the backend code. If you need to update a large number of items (1) performing multiple find with maximum page size of 1000 and (2) updating those pages in code and issuing bulkUpdate to save a page in one go, will be both much more performant and reliable.
It is also a good practice to retry the request on error, especially if queries are issued from client code where they are a bit less reliable.
Is it really advisable that in wix websites one should attempt retries on error? There is no mention of this in any of the tutorials, or the api. The error codes such as WDE0028, 53 and 55 are not documented. Also the problems I see are often not returned errors, but the code hits an “await” and is left waiting indefinitely. Is the underlying protocol TCP or UDP? If the former then errors should be handled at a lower level. Error handling is tricky, because if you assume that the lack of a response means that you need to retry, but it was actually the response that was lost, then you may duplicate the transaction. And the code is hard to test because you need a way of simulating the faults.
@giedrius-grazevicius thank you for responding.
So I have two problems with above recommendation:
-
Each row of my dataset has many columns (~300) so getting a page of 1000 rows could be very memory intensive/inefficient – especially since wix does not seem to let me query just the field of a row - but returns the entire row.
-
the wix api documentation states that “The wix-dataset API can only be used in your site’s front-end code.” – so not sure I can run this in the backend. Can you please clarify.
Thanks.
@deleteduser Thank you again - much appreciated.
Due to the instability and reliability of Wix Backend server access (including DB servers), I am beginning to believe that ALL DB and Backend access should include “retry” error handling logic. My team experiences this issue multiple times every single day that we use the system. I am trying to understand how best to do this. Does anyone have any examples of code that successfully does this with Wix.
Here is an example that should be simple to understand and modify if there is anyone that can provide a solution:
https://www.wix.com/corvid/forum/community-discussion/backend-function-call-timeout
I am desperately seeking a solution to this problem!
@tabraham You need to use wixData instead of wixDataset. WixDataset is to ease usage within the editor.
As suggested, I would recommend to do batch processing in the backend instead of requiring item one by one in the frontend.
Also A collection with 300 columns seems overly large. You might want to normalize you collection to improve performance or use tags or use text field to save json objects.
PS: that does not change the fact that collections are pretty unstable at the moment!
I agree.
We should, at least, have code documentation so we can better understand what happening. It will allow us to better debug our code and better communicate with Wix team in case of issue.
I hit Internal wixData error when updating collections from backend as well…
@plomteuxquentin thanks - now that seems more workable and is something I use in another situation – but even there I have seen these timeout issues. I hope collections become more stable soon and also the documentation on errors improves. thanks again.
@tabraham The less you make query, the less they’ll failed 
Have a look at the post of Jay Johnson where I give an example of retry mechanism 
https://www.wix.com/corvid/forum/community-discussion/backend-function-call-timeout
Thank you for your feedback. Indeed error codes and better documentation there is something we can improve.
Regarding transport - we never use UDP for anything. All Wix Data communication between client and server happens over HTTP (1.1 or 2.0).
Regarding stability issues, this is something we will investigate more deeply. Could you share your sites where this is reproducible? If you want to share discreetly, you can share editor link.
Thank you.