1

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.

  • What version were you using before the update? – Pmclain Jul 5 '17 at 23:50
  • Updated 2.1.2 to 2.1.7. Changes in messages.js were made in 2.1.3 – Rakesh Gangani Jul 6 '17 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.