Error loading web module backend/stripeProxy.jsw: Bindings not found

Hey guys:

I am experiencing a intermittent error: Error loading web module backend/stripeProxy.jsw: Bindings not found. Sometimes I get it, sometimes I don’t ( on the same code ). For context I am building a custom checkout on Wix Studio and I am calling functions in a backend module ( for security reasons ).
However, sometimes when I call them I get the error: Bindings not found. I feel like this error is out of my control and is Wix’s fault.

Here is the code:

stripeProxy.jsw ( backend module that is causing problems )

import { fetch } from 'wix-fetch';
import { STRIPE_SECRET_KEY } from 'public/PayKeys';

const apiKey = STRIPE_SECRET_KEY; // DO NOT SHARE THIS KEY
export async function charge(token, ids, amounts) {
    console.log("Sever Side: \n charge has been called \n token: " + token + "\n ids: " + ids + "\n amounts: " + amounts + "\n apiKey: " + apiKey + "\n");
    const cart = await createCart(ids, amounts);
    console.log(cart);
    const response = await fetch("https://api.stripe.com/v1/charges", {
        method: 'post',
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Authorization": "Bearer " + apiKey
        },
        body: encodeBody(token, cart)
    });
    if (response.status >= 200 && response.status < 300) {
        // transaction successful - get charge ID
        const ret = await response.json();
        // let id = await setPaidStatus(userId, ret.id);
        return { "chargeId": ret.id };
    }
    // transaction failed - return error type
    let res = await response.json();
    let err = res.error.type;
    return { "error": err };
}

function encodeBody(token, cart) {
    let encoded = "";
    for (let [k, v] of Object.entries(cart)) {
        encoded = encoded.concat(k, "=", encodeURI(v), "&");
    }
    encoded = encoded.concat("source=", encodeURI(token));
    return encoded;
}

async function createCart(ids, amounts) {
    let totalPrice = 0;
    let description = "food order: ";
    // Create an array to store all the promises returned by the wixData queries
    let promises = [];

    // Iterate over the IDs and amounts
    ids.forEach((id, i) => {
        // Push each query promise to the array
        promises.push(
            wixData.query("FoodList")
                .eq("_id", id)
                .find()
                .then((results) => {
                    totalPrice += parseFloat(results.items[0].price) * amounts[i] / 100;
                    description += results.items[0].title + " x" + amounts[i] + ", ";
                })
        );
    });

    // Wait for all the promises to resolve
    await Promise.all(promises);

    // Round totalPrice to 2 decimal places
    totalPrice = totalPrice.toFixed(2);

    // Return the cart object
    return {
        "amount": totalPrice * 100, // convert to cents
        "currency": "BGN",
        "description": description
    };
}

export async function issueOrder(ids, amounts) {

}

checkout.gwk2m.js ( front end page code ):

import wixPayFrontend from 'wix-pay-frontend';
import { local, session, memory } from "wix-storage-frontend";
import { STRIPE_PUBLISHABLE_KEY } from 'public/PayKeys';
import * as stripeProxy from 'backend/stripeProxy';
import * as stripeAPI from "public/stripeAPI";
import wixLocation from 'wix-location';
//
let ids = [];
let amounts = [];
function retrieveCart() {
    ids = JSON.parse(session.getItem("CheckoutIds"));
    amounts = JSON.parse(session.getItem("CheckoutAmounts"));
}
function displayCart() {
    let i = 0;
    ids.forEach(id => {
        console.log(id + " x" + amounts[i++] + "\n");
    });
}

$w.onReady(async function () {
    console.log("script is running");
    $w("#errorMessage").collapse();
    retrieveCart();
    displayCart();
});

$w("#PayNowButton").onClick(() => {
    $w("#errorMessage").collapse();
    $w("#PayNowButton").label = "Обработване...";
    $w("#PayNowButton").disable();
    payNow();

    console.log("payNow has been executed");
});




export function payNow() {
    stripeAPI.createToken(stripeAPI.encodeCard(createCard())) // ERROR
        .then((token) => {
            stripeProxy.charge(token, ids, amounts)
                .then((response) => {
                    if (response.chargeId) {
                        console.log("Payment Successful");
                        console.log("Charge ID: " + response.chargeId);
                        $w("#PayNowButton").label = "Готово!";
                        wixLocation.to("/thankyou");
                    }
                    else {

                        $w("#PayNowButton").label = "Плати";
                        $w("#PayNowButton").enable();
                        $w("#errorMessage").expand();
                        console.log(response.error);
                    }
                });
        });
}


function createCard() {
    let { month, year } = splitExpirationDate($w("#expiration").value);
    return {
        // @ts-ignore
        "name": $w("#cardholder").value,
        // @ts-ignore
        "number": $w("#cardnum").value,
        // @ts-ignore
        "cvc": $w("#cvc").value,
        // @ts-ignore
        "exp_year": year,
        // @ts-ignore
        "exp_month": month
    };
}

function splitExpirationDate(date) {
    const [month, year] = date.split('/');
    return { month, year };
}

From my understandings, the binding error occurs when the module is imported incorrectly or the path is different. But in this case it is completly correct ( see screenshot below ):
Screenshot 2024-04-04 at 10.19.45 AM

This is the problem. The bindings that I think are out of my control. I have also tried refreshing and reloading the project. But I haven’t had success.
Sometimes it works. It drives me mad.

Anyways, in advance, thank you guys for your attention and time!

Hey!

Checking with the team :slight_smile:

1 Like

Thanks man, did you find anything?

For the love of god, Why does it now work!? I need it to be reliable as this is how the business gets paid.

I think the error might have something to do with the stability of the network. It seems that I get it much more when I am on 4G than on Wifi. But I don’t know, to be honest.

Hi Noah. Any update on this? I have been having a similar problem today on my website. I have seen it multiple times and a customer also saw it, but then it will start working again. So it is sporadic. Hasn’t happened in the last month prior to today if I check the logs.
“Error loading web module backend/public/client.jsw: Bindings not found”

Hey!

The issue that happened last week should have been resolved.

If you’re still seeing it, a customer care ticket is the best next step (which you seem to have already opened).

I’ll send you a DM for a few more details :slight_smile:

This MIGHT just be the solution. I just got the error, then I changed my code and it worked:

For some reason sometimes you don’t get error messages in the editor ( I am using an external IDE VsCode ) on backend files ( because god knows why ). And you actually have an error, but don’t see it. I reviewed my code VERY carefully and found the mistake. Saved the thing and my backend module loaded without a problem. This is also why when I rebased my code to a working version, the error disappeared.

I still don’t know if I’m correct about this, but this is my best guess.

Hi, I still have this problem that happens randomly when trying to reach my backend through the exposed api in http-functions.js:

“[“Error loading web module backend/http-functions.js: Both resolutions failed at _load!\n\nOriginal resolver: Bindings not found\nYarnPNP: Bindings not found”]”

What modification did you do on your code to fix your issue ?

Hi Noahlovell. I’m experiencing the same binding error. it just started happening today on our site.

“[“Error loading web module backend/utility_Shop.jsw: Both resolutions failed at _load!\n\nOriginal resolver: Bindings not found\nYarnPNP: Bindings not found”]”

Any suggestions to address?

Thank you

Checking with the team again :slight_smile:


Edit - teams looking into it :muscle:

2 Likes

It’s a bit specific and probably won’t help your case, but to answer your question: I had a mismatch between returns between client side and server side function. For some reason some error checking is turned off in IDEs when working on server side files.

TIP:

Save your current work somewhere. Rebase your code to the last working version ( this should fix the binding error ) and from there try to work yourself back up to your latest version.

Thank you for your help and time. Much appreciated!
In my situation it is very wierd because when it happens, my “live” http backend (mysite.com/_functions/myfunction) stops working, but the dev one (mysite.com/_functions-dev/myfunction) works without any problem.
THe problem is that it seems random. Everything is working fine, then suddenly all calls to the http functions stop working returning a 500 error with the “YarnPNP Bindings not found” error message. Afetr a certain amount of time everything works again, then fails again, etc…
It’s driving me crazy. I tried emptying my http-functions file and recreating it with almost no content, but i still have the 500 error.

1 Like

Just so you know, I am experience the same thing. Sometimes it works and sometimes it doesn’t without changing any code.

2 Likes

Just want to loop back - the issue that was happening yesterday with this was resolved, and things should be working now.

If you’re still experiencing this issue, the best place to report is via status.wix.com, or by reporting an issue to Customer Care here.

1 Like

Confirmed, our sites are no longer experiencing the binding issue. Thank you for getting it resolved!

3 Likes

Yes, the team fixed it in my case. Would you mind sharing what the problem could be, or is it outside of our control as developers? From my understanding it’s on Wix’s side.

1 Like

Thank you for the followup! but why doesn’t that issue appear on the status page then?
I see 2 incidents happening the last 2 days, but none of them seems related to our issue

Correct, this was something from Wix end - we appreciate you raising it so we could resolve it swiftly :muscle:


Good question - while I understand it might be expected to be seen there, the status page is often used for larger impact incidents that are affecting a wide portion of users/site visitors.

From initially being picked up by the team to being resolved was a relatively short time frame. We also have our Known Issue page for longer ongoing issues.

I’ll take this feedback and chat it through with the team for consideration in the future.

2 Likes