Skip to content

Commit 1e2a0e8

Browse files
committed
Hub: fix dataset inventory error handling + GGUF cancel race
Two production bugs in the Hub: 1. Dataset inventory swallowed errors. listCachedDatasets caught 404s and JSON parse failures into an empty list, so a real backend/routing failure rendered as a confident "no datasets on device." The model and GGUF fetchers already throw on any error. Unified datasets with them so genuine failures now surface a proper Datasets error state instead of looking empty. 2. Cancelling a GGUF download could orphan it. A GGUF download resolves blob hashes before the backend claims the job. If you hit Cancel during that window, the cancel was dropped (no active job yet) and the existing re-issue safeguard got skipped, so the UI showed "cancelled" while the download kept running. Fixed so the cancel is correctly re-issued once the job is claimed, and the download actually stops.
1 parent 080c263 commit 1e2a0e8

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

‎studio/frontend/src/features/hub/download-manager/poll-loop.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,9 @@ function applyCancelResult(
747747
return;
748748
}
749749
if (live) {
750-
live.cancelRequested = false;
750+
if (result.state !== "idle") {
751+
live.cancelRequested = false;
752+
}
751753
clearWatchdog(live);
752754
}
753755
if (result.state === "complete") {

‎studio/frontend/src/features/hub/inventory/api.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,8 @@ export async function listCachedDatasets(): Promise<CachedDatasetRepo[]> {
251251
const response = await withHubTimeout(INVENTORY_TIMEOUT_MS, (signal) =>
252252
authFetch("/api/hub/datasets/cached", { signal }),
253253
);
254-
if (!response.ok) {
255-
if (response.status === 404) {
256-
console.warn(
257-
"GET /api/hub/datasets/cached returned 404 - backend may need a restart to expose the cached-datasets endpoint.",
258-
);
259-
return [];
260-
}
261-
throw new Error(
262-
await readFastApiError(response, "Couldn't scan cached datasets"),
263-
);
264-
}
265-
const data = (await response.json().catch(() => null)) as {
266-
cached?: CachedDatasetRepo[];
267-
} | null;
268-
return data?.cached ?? [];
254+
const data = await parseJsonOrThrow<{ cached: CachedDatasetRepo[] }>(response);
255+
return data.cached;
269256
}
270257

271258
export async function deleteCachedDataset(repoId: string): Promise<void> {

0 commit comments

Comments
 (0)