Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: wait for active stale chunk recovery
[._.]/ Adam Eivydc63e1b1ee68
diff --git a/client/src/utils/staleChunkReload.js b/client/src/utils/staleChunkReload.jsindex b0cd3dc3e4..3327a1eb41 100644--- a/client/src/utils/staleChunkReload.js+++ b/client/src/utils/staleChunkReload.js@@ -110,7 +110,6 @@ export const fetchServerBuildId = async () => {export const reloadOnceForStaleChunk = ({ forceCachePurge = false } = {}) => {const buildId = getCurrentBuildId();if (!buildId) return Promise.resolve(false);- if (safeReadSession(RELOAD_FLAG) === buildId) return Promise.resolve(false);if (reloadAttempts.has(buildId)) {const inFlight = reloadAttempts.get(buildId);if (!forceCachePurge) return inFlight;@@ -122,6 +121,7 @@ export const reloadOnceForStaleChunk = ({ forceCachePurge = false } = {}) => {reloaded ? true : reloadOnceForStaleChunk({ forceCachePurge: true })));}+ if (safeReadSession(RELOAD_FLAG) === buildId) return Promise.resolve(false);const attempt = (async () => {// A rejected preload can be a transient network error, and a runtime exportdiff --git a/client/src/utils/staleChunkReload.test.js b/client/src/utils/staleChunkReload.test.jsindex 53cf271815..8e9a17ca0f 100644--- a/client/src/utils/staleChunkReload.test.js+++ b/client/src/utils/staleChunkReload.test.js@@ -245,6 +245,35 @@ describe('reloadOnceForStaleChunk', () => {expect(reload).toHaveBeenCalledOnce();});+ it('waits for an automatic cache purge already in flight before retrying', async () => {+ stubSessionStorage();+ stubFetch();+ const reload = stubReload();+ let resolveCacheKeys;+ let cacheKeysStarted;+ const cacheKeysStartedPromise = new Promise((resolve) => {+ cacheKeysStarted = resolve;+ });+ vi.stubGlobal('caches', {+ keys: vi.fn(() => {+ cacheKeysStarted();+ return new Promise((resolve) => {+ resolveCacheKeys = resolve;+ });+ }),+ delete: vi.fn().mockResolvedValue(true),+ });++ const automaticAttempt = reloadOnceForStaleChunk();+ await cacheKeysStartedPromise;+ const explicitRetry = reloadOnceForStaleChunk({ forceCachePurge: true });++ expect(reload).not.toHaveBeenCalled();+ resolveCacheKeys(['portos-shell-v1']);+ await expect(Promise.all([automaticAttempt, explicitRetry])).resolves.toEqual([true, true]);+ expect(reload).toHaveBeenCalledOnce();+ });+it('does not clear cached assets on an explicit retry when the browser is offline', async () => {stubSessionStorage();stubFetch(() =>