summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/messaging_initializer/messaging_initializer.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-11-20 12:04:55 +0000
committerSébastien Theys <seb@odoo.com>2020-11-20 12:04:55 +0000
commit32ed8125aeb356e568d3c49ef7a04c0ff9e36169 (patch)
tree4fbaebb29a01b18f3d76977700faa6830ca7efe8 /addons/mail/static/src/models/messaging_initializer/messaging_initializer.js
parent4e0e8a415ae2175cd68e514cff33b2bffeb99db7 (diff)
[FIX] mail: prevent crash when initializing many failures
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) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/messaging_initializer/messaging_initializer.js')
-rw-r--r--addons/mail/static/src/models/messaging_initializer/messaging_initializer.js12
1 files changed, 6 insertions, 6 deletions
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();