0

We are experiencing an error on our Web site that prevents users from adding to the cart. We can see the error happening via recordings collected by Microsoft Clarity.

enter image description here

I believe it's coming from this code /vendor/magento/magento2-base/lib/web/js-storage/js.storage.js:

// Remove items from a storage
function _remove() {
    var storage = this._type, l = arguments.length, s = window[storage], a = arguments, a0 = a[0], to_store, tmp, i, j;
    if (l < 1) {
        throw new Error('Minimum 1 argument must be given');
    } else if (Array.isArray(a0)) {
        // If first argument is an array, remove values from storage for each item of this array
        for (i in a0) {
            if (a0.hasOwnProperty(i)) {
                s.removeItem(a0[i]);
            }
        }
        return true;
    } else if (l == 1) {
        // If only 2 arguments, remove value from storage directly
        s.removeItem(a0);
        return true;
    } else {
        // If more than 2 arguments, parse storage to retrieve final node and remove value
        // Get first level
        try {
            to_store = tmp = JSON.parse(s.getItem(a0));
        } catch (e) {
            throw new ReferenceError(a0 + ' is not defined in this storage');
        }
        // Parse next levels and remove value
        for (i = 1; i < l - 1; i++) {
            tmp = tmp[a[i]];
            if (tmp === undefined) {
                throw new ReferenceError([].slice.call(a, 1, i).join('.') + ' is not defined in this storage');
            }
        }
        // If last argument is an array,remove value for each item in this array
        // Else remove value normally
        if (Array.isArray(a[i])) {
            for (j in a[i]) {
                if (a[i].hasOwnProperty(j)) {
                    delete tmp[a[i][j]];
                }
            }
        } else {
            delete tmp[a[i]];
        }
        s.setItem(a0, JSON.stringify(to_store));
        return true;
    }
}

I am not able to recreate this error on our site.

Any suggestions on how I can track down the issue? Or what the issue might be?

2
  • Try to disable third party extension one by one and then check. Commented Jun 19 at 5:25
  • That isn't really feasible on a Production Web site. Thanks for the suggestion though.
    – cjochum
    Commented Jun 24 at 15:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.