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.
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.