From 32ed8125aeb356e568d3c49ef7a04c0ff9e36169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 20 Nov 2020 12:04:55 +0000 Subject: [FIX] mail: prevent crash when initializing many failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test highlighting the current issue has been posted in PR https://github.com/odoo/odoo/pull/62076 But it is not included as part of the current PR because it is too slow to execute, while it is unlikely we will break this fix as it is not influenced by anything else in the code. The reason why we need this change is because on some database, including ours, we have users who have more than 1000 failures still unresolved and they are all returned at init. closes odoo/odoo#62090 Signed-off-by: Alexandre Kühn (aku) --- .../models/messaging_initializer/messaging_initializer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/mail/static/src/models/messaging_initializer/messaging_initializer.js') diff --git a/addons/mail/static/src/models/messaging_initializer/messaging_initializer.js b/addons/mail/static/src/models/messaging_initializer/messaging_initializer.js index c22c197e87c..07d44355931 100644 --- a/addons/mail/static/src/models/messaging_initializer/messaging_initializer.js +++ b/addons/mail/static/src/models/messaging_initializer/messaging_initializer.js @@ -210,17 +210,17 @@ function factory(dependencies) { * @private * @param {Object} mailFailuresData */ - _initMailFailures(mailFailuresData) { - const messages = this.env.models['mail.message'].insert(mailFailuresData.map( - messageData => this.env.models['mail.message'].convertData(messageData) - )); - for (const message of messages) { + async _initMailFailures(mailFailuresData) { + await executeGracefully(mailFailuresData.map(messageData => () => { + const message = this.env.models['mail.message'].insert( + this.env.models['mail.message'].convertData(messageData) + ); // implicit: failures are sent by the server at initialization // only if the current partner is author of the message if (!message.author && this.messaging.currentPartner) { message.update({ author: [['link', this.messaging.currentPartner]] }); } - } + })); this.messaging.notificationGroupManager.computeGroups(); // manually force recompute of counter (after computing the groups) this.messaging.messagingMenu.update(); -- cgit v1.2.3