From 242a3a1717f4160f1c91989e80e434a0e67b233e Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 1 Oct 2019 22:48:33 +0200 Subject: [PATCH] Improved console reporting. --- src/lib/SyncMessage.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index 2f06d3e..a644507 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -79,7 +79,7 @@ try { if ((result = l(JSON.parse(msg), sender)) !== undefined) break; } catch (e) { - console.error(e, "Processing message %o from %o", msg, sender); + console.error("%o processing message %o from %o", e, msg, sender); } } return result instanceof Promise ? (async () => ret(await result)) : ret(result); @@ -132,17 +132,17 @@ // with "privileged" XHR browser.runtime.sendMessage({___syncMessageId: msgId}); } - // adding the payload - url += `&msg=${encodeURIComponent(JSON.stringify(msg))}`; + // then we send the payload using a privileged XHR, which is not subject + // to CORS but unfortunately doesn't carry any tab id except on Chromium + + url += `&msg=${encodeURIComponent(JSON.stringify(msg))}`; // adding the payload + let r = new XMLHttpRequest(); try { - // then we send the payload using a privileged XHR, which is not subject - // to CORS but unfortunately doesn't carry any tab id except on Chromium - let r = new XMLHttpRequest(); r.open("GET", url, false); r.send(null); return JSON.parse(r.responseText); } catch(e) { - console.error(`syncMessage error in ${document.URL}: ${e.message}`); + console.error(`syncMessage error in ${document.URL}: ${e.message} (response ${r.responseText})`); } return null; };