3

After updating Magento Framework to 2.1.7, none of the flash messages (success, error, notice ..) are show on frontend, which is making very difficult for user to understand what has happened after performing some action.

I found that in older version "mage-messages" cookie gets deleted on page load if empty, But after updating its not the same. I have 2 store view and found multiple records for mage-messages cookie.

enter image description here

Once I delete the mage-messages (session cookie) I am able to see the messages.

Is this a know issue? How can we debug such Issue?

Thank You.

Edit:

On further debugging I found there is a difference in messages.js file

on Version 2.1.3

    define([
    'jquery',
    'uiComponent',
    'Magento_Customer/js/customer-data',
    'jquery/jquery-storageapi'], function ($, Component, customerData) {
    'use strict';
    return Component.extend({
        defaults: {
            cookieMessages: [],
            messages: []
        },
        initialize: function () {
            this._super();

            this.cookieMessages = $.cookieStorage.get('mage-messages');
            this.messages = customerData.get('messages').extend({disposableCustomerData: 'messages'});
            $.cookieStorage.setConf({path: '/', expires: -1}).set('mage-messages', null);
        }
    });
});

Where as on Version 2.1.7 code is

    define([
    'jquery',
    'uiComponent',
    'underscore',
    'Magento_Customer/js/customer-data',
    'jquery/jquery-storageapi'], function ($, Component, _, customerData) {
    'use strict';

    return Component.extend({
        defaults: {
            cookieMessages: [],
            messages: []
        },

        /** @inheritdoc */
        initialize: function () {
            this._super();

            this.cookieMessages = $.cookieStorage.get('mage-messages');
            this.messages = customerData.get('messages').extend({
                disposableCustomerData: 'messages'
            });

            if (!_.isEmpty(this.messages().messages)) {
                customerData.set('messages', {});
            }

            $.cookieStorage.set('mage-messages', '');
        }
    });
});

Seems the new versions is making use of underscore. Also noticed that below code is removed in new version

.setConf({path: '/', expires: -1})

I believe this issue is occurred with sites having multiple store views.

3
  • What version were you using before the update?
    – Pmclain
    Commented Jul 5, 2017 at 23:50
  • Updated 2.1.2 to 2.1.7. Changes in messages.js were made in 2.1.3 Commented Jul 6, 2017 at 8:33
  • @RakeshGangani, Any update for this issue? Because, I face the same issue after upgrade 2.3.4 to 2.4.2p1. I can't get any solution and now I'm stuck. Commented Jun 30, 2021 at 12:46

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.