diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index e6946b99b..677243399 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -879,7 +879,8 @@ define([ postMessage("LEAVE_PAD", data, cb); }; pad.sendPadMsg = function (data, cb) { - postMessage("SEND_PAD_MSG", data, cb); + // -1 ==> no timeout, we may receive the callback only when we reconnect + postMessage("SEND_PAD_MSG", data, cb, { timeout: -1 }); }; pad.onReadyEvent = Util.mkEvent(); pad.onMessageEvent = Util.mkEvent(); diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 4fe64aad7..da7f043f3 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1596,7 +1596,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/outer/worker-channel.js b/www/common/outer/worker-channel.js index 42b91b802..545ce435b 100644 --- a/www/common/outer/worker-channel.js +++ b/www/common/outer/worker-channel.js @@ -45,10 +45,13 @@ define([ var txid = mkTxid(); opts = opts || {}; var to = opts.timeout || 30000; - var timeout = setTimeout(function () { - delete queries[txid]; - cb('TIMEOUT'); - }, to); + var timeout; + if (to > 0) { + timeout = setTimeout(function () { + delete queries[txid]; + cb('TIMEOUT'); + }, to); + } acks[txid] = function (err) { clearTimeout(timeout); delete acks[txid]; diff --git a/www/common/sframe-chainpad-netflux-inner.js b/www/common/sframe-chainpad-netflux-inner.js index a55463bb7..df81be9fd 100644 --- a/www/common/sframe-chainpad-netflux-inner.js +++ b/www/common/sframe-chainpad-netflux-inner.js @@ -61,10 +61,12 @@ define([ logLevel: logLevel }); _chainpad.onMessage(function(message, cb) { - sframeChan.query('Q_RT_MESSAGE', message, function (err) { + // -1 ==> no timeout, we may receive the callback only when we reconnect + sframeChan.query('Q_RT_MESSAGE', message, function (_err, obj) { + var err = _err || (obj && obj.error); if (!err) { evPatchSent.fire(); } cb(err); - }); + }, { timeout: -1 }); }); _chainpad.onPatch(function () { onRemote({ realtime: chainpad });