From 5dcf67476166ddfcb6b2fdc3f76d0ffb4e8074e3 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sun, 30 Mar 2025 14:54:29 +0200 Subject: [PATCH] webmail: reconnect automatically in more cases Before, we would only reconnect the SSE connection when the previous one lasted 10 minutes. For some reason, firefox disconnects SSE connections when there is any network change. Running the docker integration tests changes the network a few time in quick succession, prevent further automatic reconnects. This changes the "stop reconnection automatically" period from 10 minutes to 5 seconds. --- webmail/webmail.js | 6 ++++-- webmail/webmail.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/webmail/webmail.js b/webmail/webmail.js index 8df4968..26f9dcc 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -7005,7 +7005,6 @@ const init = async () => { connectionElem.classList.toggle('loading', true); dom._kids(connectionElem); connectionElem.classList.toggle('loading', false); - // We'll clear noreconnect when we've held a connection for 10 mins. noreconnect = isreconnect; connecting = true; let token; @@ -7194,10 +7193,13 @@ const init = async () => { } dom._kids(queryactivityElem, 'loading...'); msglistscrollElem.appendChild(listloadingElem); + // We'll clear noreconnect when we've held a connection for 5 seconds. Firefox + // disconnects often, on any network change including with docker container starts, + // such as for integration tests. noreconnectTimer = setTimeout(() => { noreconnect = false; noreconnectTimer = 0; - }, 10 * 60 * 1000); + }, 5 * 1000); }); eventSource.addEventListener('viewErr', async (e) => { const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data))); diff --git a/webmail/webmail.ts b/webmail/webmail.ts index 06bf74d..dfaad76 100644 --- a/webmail/webmail.ts +++ b/webmail/webmail.ts @@ -7271,7 +7271,6 @@ const init = async () => { dom._kids(connectionElem) connectionElem.classList.toggle('loading', false) - // We'll clear noreconnect when we've held a connection for 10 mins. noreconnect = isreconnect connecting = true @@ -7473,10 +7472,13 @@ const init = async () => { dom._kids(queryactivityElem, 'loading...') msglistscrollElem.appendChild(listloadingElem) + // We'll clear noreconnect when we've held a connection for 5 seconds. Firefox + // disconnects often, on any network change including with docker container starts, + // such as for integration tests. noreconnectTimer = setTimeout(() => { noreconnect = false noreconnectTimer = 0 - }, 10*60*1000) + }, 5*1000) }) eventSource.addEventListener('viewErr', async (e: MessageEvent) => { const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data)))