Web Module will not load in Live Site

I have a web module (.jsw) that loads and executes in Preview mode, but will not load in my Live site.

This is the page code that calls the web module:

import wixData from ‘wix-data’;
import {billingCode} from ‘backend/calc_billing’;
import {updateBilling} from ‘backend/calc_billing’;

$w.onReady( async function () {

})

export async function billingButton_click(event) {
let billing = await billingCode();
let finish = await updateBilling(billing);
console.log(billing);
$w(‘#textBox1’).value = JSON.stringify(billing);
}

When the onClick event is fired, I receive the following in the Chrome developer console:


As best I can tell, the error points to " import {billingCode} from ‘backend/calc_billing’;", implying that this resource cannot be loaded.

So the question is why would the same .jsw module load fine in Preview, but not on the live site? Site URL is naturallakes.net, page is “Calculate Billing”.

#jsw_issue #preview_vs_live

@yisrael-wix Sorry to bother you, but I am kind of dead in the water on this issue, and at least need some guidance on where to look. Thanks in advance

Hi Dave, I will try to help you with your site. Can you tell me which page has the page code that you referred to in your first message?

@chaim-kram Appreciate the help. The Page Code that calls the .jsw module is on “Calculate Billing” (as noted above); however. I have started to move in another direction because this issue has been lingering for quite a while. The calling code above and the .jsw module can still be used to test this issue on a test bed. It seems like there is something in the “wrapper” code that Wix uses, because the error occurred immediately after invoking the .jsw module – none of my code within the module ever executed (on the Live side).

@davebogan98 , I think I narrowed down your Uncaught Promise error to the following code in backend file ‘calc_billing.jsw’:

for (let i = 0; i < memArray.length; i++) {
   let billcode = await billArray.find(function (element) {
      if (element.memberID === memArray[i]._id) {
         return element;
      }
   })
   memArray[i].billingCode = billcode.billing;
}

When I commented this out, the code started working. I’m not sure exactly what’s going on in here or why it isn’t working, but if you focus on this you might be able to track it down. If you do and you find that is still doing something that is unexpected, and you suspect it’s a bug on our end, please follow up with us.

(BTW, in my cloned site I added a function to insert messages into a database, which currently is the only way to log messages from a backend file. console.log( ) will not work because those messages are not visible anywhere.)

Good luck!

@chaim-kram Thanks for checking it out – I’ll take it from here. Appreciate the extra effort!