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: keep a pending data overview scan shared past the cache TTL (#13077)
[._.]/ Adam Eivyc65bb1d10715
diff --git a/server/services/dataManager.js b/server/services/dataManager.jsindex ff9e2297f9..222b5b97ee 100644--- a/server/services/dataManager.js+++ b/server/services/dataManager.js@@ -360,7 +360,7 @@ async function getDirSizeAndCount(dirPath, { strict = false } = {}) {// The scan is the multi-second part of the overview (du + a recursive walk per// category), and the Data page, the resources report and the data-introspection// harbor all request it. Share one result per `strict` mode for a short window-// and coalesce concurrent callers; mutations here invalidate it. Rejections are+// after it completes and coalesce concurrent callers while it is pending; mutations here invalidate it. Rejections are// never cached. Busy state and disk capacity are read fresh on every call.const OVERVIEW_SCAN_TTL_MS = 30_000;const overviewScans = new Map();@@ -411,13 +411,17 @@ async function scanDataTree(strict) {function getCachedOverviewScan(strict) {const cached = overviewScans.get(strict);- if (cached && Date.now() - cached.at < OVERVIEW_SCAN_TTL_MS) return cached.promise;+ // A pending scan is always shared; the TTL starts when it fulfills.+ if (cached && (cached.at === null || Date.now() - cached.at < OVERVIEW_SCAN_TTL_MS)) return cached.promise;const promise = scanDataTree(strict);- const entry = { at: Date.now(), promise };+ const entry = { at: null, promise };overviewScans.set(strict, entry);- promise.catch(() => {- if (overviewScans.get(strict) === entry) overviewScans.delete(strict);- });+ promise.then(+ () => { entry.at = Date.now(); },+ () => {+ if (overviewScans.get(strict) === entry) overviewScans.delete(strict);+ },+ );return promise;}diff --git a/server/services/dataManager.strict.test.js b/server/services/dataManager.strict.test.jsindex df43aa95f4..d39ec76e34 100644--- a/server/services/dataManager.strict.test.js+++ b/server/services/dataManager.strict.test.js@@ -152,3 +152,36 @@ it('reports an unreadable data root as an unknown count rather than an empty treexpect(overview.categories).toEqual([]);expect(overview.totalFileCount).toBeNull();});++describe('overview scan cache lifecycle', () => {+ it('shares a still-pending scan past the TTL, then expires the completed result', async () => {+ const release = [];+ let held = true;+ mocks.execFile.mockImplementation((command, args, _options, callback) => {+ const target = command === 'find' ? args[0] : args[args.length - 1];+ const respond = () => callback(null, { stdout: `1\t${target}\n`, stderr: '' });+ if (held) release.push(respond); else respond();+ });+ const first = getDataOverview();+ await vi.waitFor(() => expect(release.length).toBeGreaterThan(0));+ const started = mocks.execFile.mock.calls.length;++ vi.setSystemTime(Date.now() + 45_000);+ const second = getDataOverview();+ await new Promise((resolve) => setTimeout(resolve, 50));+ expect(mocks.execFile.mock.calls.length).toBe(started);++ held = false;+ while (release.length) release.shift()();+ await Promise.all([first, second]);+ const completed = mocks.execFile.mock.calls.length;++ vi.setSystemTime(Date.now() + 10_000);+ await getDataOverview();+ expect(mocks.execFile.mock.calls.length).toBe(completed);++ vi.setSystemTime(Date.now() + 31_000);+ await getDataOverview();+ expect(mocks.execFile.mock.calls.length).toBeGreaterThan(completed);+ });+});