From d69ad7c0e6d84c46c1febeae4439ee93043bd672 Mon Sep 17 00:00:00 2001
From: yflory <yann.flory@xwiki.com>
Date: Mon, 16 Mar 2020 12:06:18 +0100
Subject: [PATCH] Send the error to chainpad when a patch is not sent

---
 www/common/outer/async-store.js             | 5 ++++-
 www/common/sframe-chainpad-netflux-inner.js | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js
index 497babd22..bb30014d1 100644
--- a/www/common/outer/async-store.js
+++ b/www/common/outer/async-store.js
@@ -1599,7 +1599,10 @@ define([
                 onConnect: function (wc, sendMessage) {
                     channel.sendMessage = function (msg, cId, cb) {
                         // Send to server
-                        sendMessage(msg, function () {
+                        sendMessage(msg, function (err) {
+                            if (err) {
+                                return void cb({ error: err });
+                            }
                             // Broadcast to other tabs
                             channel.pushHistory(CpNetflux.removeCp(msg), /^cp\|/.test(msg));
                             channel.bcast("PAD_MESSAGE", {
diff --git a/www/common/sframe-chainpad-netflux-inner.js b/www/common/sframe-chainpad-netflux-inner.js
index c786f7009..f7d0ada00 100644
--- a/www/common/sframe-chainpad-netflux-inner.js
+++ b/www/common/sframe-chainpad-netflux-inner.js
@@ -60,7 +60,8 @@ define([
         });
         chainpad.onMessage(function(message, cb) {
             // -1 ==> no timeout, we may receive the callback only when we reconnect
-            sframeChan.query('Q_RT_MESSAGE', message, function (err) {
+            sframeChan.query('Q_RT_MESSAGE', message, function (_err, obj) {
+                var err = _err || (obj && obj.error);
                 if (!err) { evPatchSent.fire(); }
                 cb(err);
             }, { timeout: -1 });