jamiepine/voicebox · warning · HTTPException

CUDA backend download already in progress

Error message

CUDA backend download already in progress

What it means

HTTP 409 raised by POST /backend/download-cuda when the progress manager reports an existing entry for the 'cuda-backend' key with status 'downloading'. This guards against kicking off a second concurrent download while one is already in flight. The check is advisory (a TOCTOU window exists that the service-level _download_lock also covers), so the response means: a download is already running, subscribe to progress instead.

Source

Thrown at backend/routes/cuda.py:39

    return cuda.get_cuda_status()


@router.post("/backend/download-cuda")
async def download_cuda_backend():
    """Download the CUDA backend binary."""
    from ..services import cuda

    unsupported_reason = cuda.get_cuda_download_unsupported_reason()
    if unsupported_reason:
        raise HTTPException(status_code=409, detail=unsupported_reason)

    if cuda.get_cuda_binary_path() is not None:
        raise HTTPException(status_code=409, detail="CUDA backend already downloaded")

    progress_manager = get_progress_manager()
    existing = progress_manager.get_progress(cuda.PROGRESS_KEY)
    if existing and existing.get("status") == "downloading":
        raise HTTPException(status_code=409, detail="CUDA backend download already in progress")

    async def _download():
        try:
            await cuda.download_cuda_binary()
        except Exception as e:
            logger.error("CUDA download failed: %s", e)

    create_background_task(_download())
    return {"message": "CUDA backend download started", "progress_key": "cuda-backend"}


@router.delete("/backend/cuda")
async def delete_cuda_backend():
    """Delete the downloaded CUDA backend binary."""
    from ..services import cuda

    if cuda.is_cuda_active():
        raise HTTPException(

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Subscribe to GET /backend/cuda-progress (SSE) to observe the in-flight download instead of re-POSTing.
  2. Disable the download button while status.downloading is true.
  3. Debounce/dedupe the download action in the client.

Example fix

// before
setInterval(() => fetch('/backend/download-cuda', { method: 'POST' }), 5000);
// after
const status = await fetch('/backend/cuda').then(r => r.json());
if (status.downloading) { /* attach to SSE progress */ return; }
await fetch('/backend/download-cuda', { method: 'POST' });
Defensive patterns

Strategy: validation

Validate before calling

const status = await fetch('/backend/cuda').then(r => r.json());
if (status.downloading) throw new Error('download already running');

Type guard

function isCudaDownloading(s): s is { downloading: true } { return s?.downloading === true; }

Try / catch

const r = await fetch('/backend/download-cuda', { method:'POST' });
if (r.status === 409 && (await r.json()).detail.includes('in progress')) { /* subscribe to SSE progress */ }

Prevention

When it happens

Trigger: Calling POST /backend/download-cuda while a prior download (manual or auto-update) is still running.

Common situations: User double-clicks the download button; the startup auto-update is mid-download when the user also clicks download; a retry fired before the first request finished.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/34de20404cb2e780. Report an issue: GitHub.