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.
This commit is contained in:
Mechiel Lukkien 2025-03-30 14:54:29 +02:00
parent aba0061073
commit 5dcf674761
No known key found for this signature in database
2 changed files with 8 additions and 4 deletions

View File

@ -7005,7 +7005,6 @@ const init = async () => {
connectionElem.classList.toggle('loading', true); connectionElem.classList.toggle('loading', true);
dom._kids(connectionElem); dom._kids(connectionElem);
connectionElem.classList.toggle('loading', false); connectionElem.classList.toggle('loading', false);
// We'll clear noreconnect when we've held a connection for 10 mins.
noreconnect = isreconnect; noreconnect = isreconnect;
connecting = true; connecting = true;
let token; let token;
@ -7194,10 +7193,13 @@ const init = async () => {
} }
dom._kids(queryactivityElem, 'loading...'); dom._kids(queryactivityElem, 'loading...');
msglistscrollElem.appendChild(listloadingElem); 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(() => { noreconnectTimer = setTimeout(() => {
noreconnect = false; noreconnect = false;
noreconnectTimer = 0; noreconnectTimer = 0;
}, 10 * 60 * 1000); }, 5 * 1000);
}); });
eventSource.addEventListener('viewErr', async (e) => { eventSource.addEventListener('viewErr', async (e) => {
const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data))); const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data)));

View File

@ -7271,7 +7271,6 @@ const init = async () => {
dom._kids(connectionElem) dom._kids(connectionElem)
connectionElem.classList.toggle('loading', false) connectionElem.classList.toggle('loading', false)
// We'll clear noreconnect when we've held a connection for 10 mins.
noreconnect = isreconnect noreconnect = isreconnect
connecting = true connecting = true
@ -7473,10 +7472,13 @@ const init = async () => {
dom._kids(queryactivityElem, 'loading...') dom._kids(queryactivityElem, 'loading...')
msglistscrollElem.appendChild(listloadingElem) 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(() => { noreconnectTimer = setTimeout(() => {
noreconnect = false noreconnect = false
noreconnectTimer = 0 noreconnectTimer = 0
}, 10*60*1000) }, 5*1000)
}) })
eventSource.addEventListener('viewErr', async (e: MessageEvent) => { eventSource.addEventListener('viewErr', async (e: MessageEvent) => {
const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data))) const viewErr = checkParse(() => api.parser.EventViewErr(JSON.parse(e.data)))