From 607d7986651461eb912ef14081e247c9915d91f7 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 25 Jun 2019 21:33:41 +0200 Subject: [PATCH] Store session per full JID Otherwise we run into a bug where two tabs with Converse.js share the same XEP-0198 SM-ID, causing both to go into a reconnection-loop as the XMPP server switches XEP-0198 sessions between them. This bug is due to a distinction in how sessionStorage behaves when you open the existing site in a new tab (e.g. middle-click or `target="_blank"), as opposed to creating a new tab and then opening the site in that tab. In the latter case, the newly created sessionStorage object is empty. In the former, the contents of sessionStorage of the current page is copied over to the new page! --- src/headless/converse-core.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/headless/converse-core.js b/src/headless/converse-core.js index 211d7aba3..6def661d6 100644 --- a/src/headless/converse-core.js +++ b/src/headless/converse-core.js @@ -506,8 +506,10 @@ _converse.initConnection = function () { async function initUserSession (jid) { - const bare_jid = Strophe.getBareJidFromJid(jid); - const id = `converse.session-${bare_jid}`; + // XXX: Important to use full JID, otherwise we run into a bug where two + // tabs with share the same XEP-0198 SM-ID, causing them to go into a + // reconnection-loop. + const id = `converse.session-${jid}`; if (!_converse.session || _converse.session.get('id') !== id) { _converse.session = new Backbone.Model({id}); _converse.session.browserStorage = new BrowserStorage.session(id);