fix: recover deferred workspace reconnects
CI / lint (pull_request) Successful in 2m53s
CI / build-release (pull_request) Successful in 6s
CI / browser-journey (pull_request) Failing after 2m45s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-17 02:16:48 +00:00
1 parent 377fd889c5
commit 0fc152f623
6 files changed
+128 -7

No files matched your search

+3 -3
View File
@@ -7331,6 +7331,9 @@
flushAuthored: flushAuthoredOutbox,
flushNotificationReads: flushNotificationReadOutbox,
});
const reconnectAfterOnline = () => setTimeout(reconnectOutboxes, 500);
window.addEventListener('online', reconnectAfterOnline);
workspaceLifecycle.replayOnline(reconnectAfterOnline);
async function setOfflineWorkEnabled(enabled) {
keepWorkOffline.checked = enabled;
offlineWorkStore.setEnabled(enabled);
@@ -7388,9 +7391,6 @@
updateDeliveryReceiptControls();
if (!navigator.onLine) await showOfflineStatus();
window.addEventListener('offline', showOfflineStatus);
const reconnectAfterOnline = () => setTimeout(reconnectOutboxes, 500);
window.addEventListener('online', reconnectAfterOnline);
workspaceLifecycle.replayOnline(reconnectAfterOnline);
qs('#refresh').addEventListener('click', load);
qs('#plan-today').addEventListener('click', event => openPlanToday(event.currentTarget));
+20 -1
View File
@@ -5,7 +5,10 @@ function createReconnectOutboxes({
flushAuthored,
flushNotificationReads,
}) {
return async function reconnectOutboxes() {
let activeReconnect = null;
let followUpRequested = false;
async function reconnectOnce() {
const snapshot = await refresh();
const freshness = snapshot?.freshness?.sections?.context;
const identityFresh = snapshot?.context && !snapshot.context.error &&
@@ -19,6 +22,22 @@ function createReconnectOutboxes({
flushNotificationReads(),
]);
return true;
}
return function reconnectOutboxes() {
if (activeReconnect) {
followUpRequested = true;
return activeReconnect;
}
activeReconnect = (async () => {
let result = false;
do {
followUpRequested = false;
result = await reconnectOnce();
} while (followUpRequested);
return result;
})().finally(() => { activeReconnect = null; });
return activeReconnect;
};
}
+7 -2
View File
@@ -25,9 +25,14 @@ async function loadWorkspace({ document, window = null, createLoader = createFea
};
} catch (error) {
window?.removeEventListener('online', captureOnline);
if (window?.location?.reload) {
if (cameOnline) window.location.reload();
else window.addEventListener('online', () => window.location.reload(), { once: true });
}
if (status) {
status.textContent =
'Workspace could not load. Check your connection, then reload to retry.';
status.textContent = window
? 'Workspace could not load. Reconnect to retry automatically, or reload now.'
: 'Workspace could not load. Check your connection, then reload to retry.';
}
throw error;
}