Skip to content

Bug: Non-RuntimeError exceptions leave videos stuck in DOWNLOADING status indefinitely #28

@windoze95

Description

@windoze95

Description

In app/tasks/download_tasks.py (~line 218), the download_video_task attempts to handle task failures by setting the video status to FAILED:

    except Exception as exc:
        logger.exception("Download failed for video %s", video_id)
        # Mark as FAILED if we've exhausted retries
        try:
            video = db.get(Video, video_id)
            if video and self.request.retries >= self.max_retries:
                video.status = "FAILED"
                db.commit()

However, if an exception occurs that is not included in autoretry_for=(RuntimeError,) (such as a database error, missing file, or JSON parsing failure), the task crashes immediately on the first attempt where self.request.retries is 0.

Since 0 >= 3 is false, the status is never updated to FAILED. The task dies, and the video is permanently stuck in the DOWNLOADING state, locking up the UI.

Suggested Fix

Modify the exception block to mark the video as FAILED if the retry limit is exhausted OR if the exception being caught is not retryable (i.e. this is the final terminal failure).

File Path

app/tasks/download_tasks.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood-first-issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions