Web Module Timeout?

I have been using backend web modules to execute wixData operations against large collections (more than 500 items) because the performance is better than in front end code. I have noticed that the console in Developer Tools (I use Chrome) is throwing this error message:

c3p66.js:2 Uncaught (in promise) Error: WebMethod request timed-out after 14 seconds… Did you forget to resolve a promise?

All the of the wixData operations finish, despite this message. I have my own console message that appears when all operations are completed. If I only process a few records, I get my message. If I process a large number of records – like over 500 – then my message never shows up because of the timeout error message. Effectively, it means that code following large data operations will never execute.

I imagine that this is prevent “runaway” backend functions, but anyone running large data operations might bump into this. Not sure if this is a bug, or a feature.

It might be nothing, or it might be something. I’m checking this with QA.

Thanks. Any update you can share?

Hey @davebogan98 , I discussed this with the developers and it ends up that the message you are receiving, although “scary”, is in fact “nothing”. Well, it’s nothing for you, but it’s a condition that the developers are interested it. Unfortunately, it’s not so easy to hide these messages from the users, so messages of this type will appear from time to time.

Thanks, @yisrael-wix . I know that the error does not seem to cause a problem with what the web module does, but it does prevent any subsequent code from executing – like a completion message – which can be problematic depending upon the function being performed. It does seem a bit arbitrary that someone chose 14 seconds as the cutoff for how long a web module can take to respond…

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved and the scenario showing the problem.

@yisrael-wix Here is the relevant information…

The page with the calling code is JSON Import-Export; this calls web module uploadJSON.jsw. This process takes a JSON file to load a collection by inserting an item, and then inserting the multi-item reference field for that item. In the case of the Member_Parcel collection, a member may have multiple parcels, but a parcel can only belong to one member. I know that this kind of relationship can be created using regular reference fields, but if one is looking for all the parcels that belong to a member, the multi-item reference field makes this much simpler and faster. If your folks need the JSON file, let me know where I can send that.

@yisrael-wix Hi – any updates on this you can share?

@yisrael-wix I have been doing some further testing (just can’t let it go) and I think the problem is with the multi-item reference field API implementation.

Here is the scenario: I have two collections connected via a multi-item reference field – Members, which contains 310 items, and Parcels, which contains 502 items. A Member may have more than one Parcel, but a Parcel can only belong to one Member. So, on average, a Member has 1.6 Parcels.

I am using a multi-item reference field because I need to traverse the relationship from Member to Parcel. (A single-item reference field would not let me do this.) The business function is collect the type of Parcels belonging to each Member, then determine a status for the Member based upon the analysis of the Parcel types found.

Here is the web module code. I pass the function a count of Members to retrieve as part of testing; ultimately, the function will spin through all 310 Members. The output of the function is an array containing the Member identifier and a sub-array containing the Parcels for that Member.

export async function arrayBilling(limitcount){
var memArray = [];
var parcelArray = [];
var testArray = [];
var subArray = [];

let memresult = await wixData.query(“Members”)
.limit(limitcount)
.find()

memArray = memresult.items; 

for(let m = 0; m<memArray.length;m++) {
let parcelresult = await wixData.queryReferenced(“Members”, memArray[m]._id, “Parcel”)
parcelArray = parcelresult.items;
subArray = [];
for ( let p =0; p<parcelArray.length;p++) {
subArray.push({ “vcc”: parcelArray[p].parcelVcc, “type”: parcelArray[p].parcelType });
}
testArray.push({
“member”: memArray[m].memberId,
“parcels”: subArray,
})
}
return testArray
}

Running this as web module from the backend, I get the following results:

For 10 Members, the function takes 2.4 seconds
For 100 Members, the function takes 6.4 seconds
For 310 Members, the function does not complete, throwing the 14 second timeout error.

If I run the module, but only create memArray (so not executing the wixData.queryReferenced() portion of the code, then the module takes about 1 second whether the limitcount is 10, 100, or 310. This tells me that the majority of the time is being taken in the wixData.queryReferenced() calls.

I suspect that when the wixData.queryReferenced() call is made, is uses a query (scan) type of call, rather than a get (we know the _id) type of call, to process the related Parcels. If so, that would mean the call is reading 1.6 x 502 = 803 Parcels for each Member and 310 x 803 = 248,930 reads for all Members. If the wixData.queryReferenced() was using a get type call, the total would be 310 X1.6 = 496.

This would explain why the web module timeout error gets thrown. I’d ask that you bring this to the developers and see what they have to say. My concern is that this poor performance with a small number of items makes multi-item reference fields a non-starter for any application of volume.

@davebogan98 Nice job! I’m passing this on to QA for evaluation. Thanks

Please post the JSON, or you can send it via PM.

Thanks

@yisrael-wix I no longer have the JSON files; as I moved to another method since then. I think my comments about multi-item reference field performance should be sufficient for the QA people.

@yisrael-wix Anything to share? Are the developers at least saying, “Hmmm…”?

@davebogan98 Not aware of any issues. The JSON would have been helpful to point out the specific issue.

@yisrael-wix So… you are telling me that what I shared in my post of January 11 – which is simply querying a collection and following a multi-item reference – is not an issue or not something that Wix is dealing with at this time?

@davebogan98 No, I’m just stating that I’m not aware of any issues. The developers requested the JSON in order to investigate the problem. The issue might have been related to your specific data (JSON), but there is no JSON now.

@yisrael-wix Sorry if I was a bit snarky. While I can understand the desire for the JSON, the research I did on Jan 11 did not involve any JSON input, yet the same timeout error got thrown. Am happy to Skype with the appropriate folks to discuss further if needed.

I think the multi-item reference fields are a great addition to Wix Code; I would just like to see better performance when using them.

@davebogan98 Hey, don’t worry about it. I know how it is… :beers:

Wix is always working on performance and we greatly appreciate customer feedback. The biggest problem for the developers is being able to reproduce a problematic scenario in order to identify problems. Sometimes problems pop up with “regular” data, other times it’s “because of” (something).

If you can reproduce a problematic scenario, I’d be glad to send it on to the developers.