netresearch / dhl-module-ui

Module for providing the presentation layer within the Magento application for custom functionality
Open Software License 3.0
3 stars 0 forks source link

cannot use 'in' operator to search for "carriers" #10

Closed YiffyToys closed 3 years ago

YiffyToys commented 3 years ago

There seems to be some missing error handling, potentially causing customer-facing Javascript issues after selecting a shipping method in checkout and before "next" reacts. The browser just freezes and the user can not check out with any shipping method. Disabling the module dhl/module-ui worked around that issue but also removes the admin ui for creating DHL parcels.

The Exception happened in this line: https://github.com/netresearch/dhl-module-ui/blob/master/view/base/web/js/model/shipping-settings.js#L131

Aparently settings() returns not an object but a string "An error has happened during application run. See exception log for details." and the code requires the returned valued to be a string. It should check the type or handle the exception to at least allow the checkout with any shipping method, even if the DHL UI to select a parcel station can not be shown.

    getByCarrier https://shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/Dhl_Ui/js/model/shipping-settings.js:131
    refresh https://shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/Dhl_Ui/js/view/shipping-options-area.js:103
    notifySubscribers https://shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/knockoutjs/knockout.js:1320
    valueHasMutated https:/shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/knockoutjs/knockout.js:1538
    observable https://shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/knockoutjs/knockout.js:1504
    <anonymous> https://shop/static/version1619770669/frontend/yiffytoys/yttheme/en_GB/Magento_Checkout/js/action/select-shipping-method.js:15

FYI: It was called by the following code because there was a non-existing theme configured for the 404 and cookies pages. The cause has been fixed but the error handling should still be performed in the outlined place as any error there breaks the entire checkout process not only for DHL but for all other shipping services too. (low probability but critical impact)

shippingService.isLoading(true);
        request.post(
            serviceUrl,
            JSON.stringify(payload)
        ).success(
            function (response) {
                storage.set(countryId + postalCode, response);
                checkoutData.set(response);   <<<<<<<<<< response="An error has happened during application run. See exception log for details."
                shippingService.isLoading(false);
            }
        )
powli commented 3 years ago

Nice find, we will have a look at it.

mam08ixo commented 3 years ago

We introduced a type check in Netresearch_ShippingUi version 2.0.2 (used in DHL Shipping v2). There are no plans to backport the change to this repository.