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
address review (self): stop swallowing a failed download in ALL-must-succeed repo mode
[._.]/ Adam Eivy6436ce28bc27
diff --git a/server/lib/sseDownload.js b/server/lib/sseDownload.jsindex 2baabd11aa..deab1d7fd9 100644--- a/server/lib/sseDownload.js+++ b/server/lib/sseDownload.js@@ -177,7 +177,22 @@ export async function startHfDownloadStream({ req, res, repo, repos, fallbacks,currentHandle = null;}if (!firstSuccessWins) {+ // ALL must succeed here — unlike the fallback-chain branch below, there+ // is no next candidate to fall through to. Silently treating a failed+ // repo as done (the prior bug) let the loop reach `complete` even+ // though one of the required repos never downloaded.+ if (!result?.ok) {+ if (result?.errorKind === 'cancelled') return safeEnd();+ send({+ type: 'error',+ kind: result?.errorKind || 'download_failed',+ message: `${r}: ${result?.errorMessage || 'unknown error'}`,+ repo: r,+ });+ return safeEnd();+ }downloadedAny = true;+ totalSize += result.sizeBytes || 0;continue;}if (result?.ok) {diff --git a/server/lib/sseDownload.test.js b/server/lib/sseDownload.test.jsindex 028b67ca42..f4ac0be3d6 100644--- a/server/lib/sseDownload.test.js+++ b/server/lib/sseDownload.test.js@@ -323,3 +323,40 @@ describe('startHfDownloadStream single-file + fallbacks (#3112)', () => {expect(parseFrames(frames)).toEqual([{ type: 'error', message: 'No repo specified for download.' }]);});});++// ── Multi-repo `repos:` — ALL must succeed, unlike `fallbacks` above ────────+describe('startHfDownloadStream repos (ALL must succeed)', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ inspectModelCache.mockResolvedValue({ cached: false, sizeBytes: 0, snapshotPath: null });+ });++ it('reports an error and stops when one of several required repos fails, instead of completing', async () => {+ downloadHfRepo+ .mockReturnValueOnce({ promise: Promise.resolve({ ok: true, sizeBytes: 100 }), kill: vi.fn() })+ .mockReturnValueOnce({+ promise: Promise.resolve({ ok: false, errorKind: 'download_failed', errorMessage: 'network reset' }),+ kill: vi.fn(),+ });++ const { req, res, frames } = makeReqRes();+ await startHfDownloadStream({ req, res, repos: ['org/repo-a', 'org/repo-b'] });++ const parsed = parseFrames(frames);+ expect(parsed.some((f) => f.type === 'complete')).toBe(false);+ expect(parsed.at(-1)).toMatchObject({ type: 'error', repo: 'org/repo-b' });+ // A required repo failing must stop the chain rather than rolling on.+ expect(downloadHfRepo).toHaveBeenCalledTimes(2);+ });++ it('completes once every required repo succeeds', async () => {+ // Explicit mockReturnValue (not -Once) so this test's total doesn't depend+ // on how many queued mockReturnValueOnce entries earlier tests left behind.+ downloadHfRepo.mockReturnValue({ promise: Promise.resolve({ ok: true, sizeBytes: 100 }), kill: vi.fn() });+ const { req, res, frames } = makeReqRes();+ await startHfDownloadStream({ req, res, repos: ['org/repo-a', 'org/repo-b'] });++ const parsed = parseFrames(frames);+ expect(parsed.at(-1)).toMatchObject({ type: 'complete', repos: ['org/repo-a', 'org/repo-b'], sizeBytes: 200 });+ });+});