tus / tus/TUSKit

[V2.2.0] Upload Cleanup Fails to Delete File, Causing Stale Files and Permanent Upload Hang

Open
#202 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
245
Forks
128
PR merge metrics
No merged PRs in 30d

Description

[V2.2.0] Upload Cleanup Fails to Delete File After Successful Upload, Leading to Inconsistent State

Description

In version 2.2.0, after an upload completes successfully, the cleanup process fails to delete the uploaded file from the system due to an unknown reason I faced. As a result:

  • The uploaded file remains in the storage.
  • The upload object is removed from currentUploads.
  • If a createOrResume is called later, the file will be detected as existing, but earlierUpload == nil. The upload status becomes nil, reaching an unhandled state, leading to this upload task permanently hanging no matter how many times it is retried.

Steps to Reproduce

  1. Start an upload using TUSKit.
  2. Let the upload complete successfully.
  3. Observe that during cleanup, force trigger an error when deleting the file to simulate the case.
  4. The upload entry is removed from currentUploads, but the file remains.
  5. Retry the same upload; the system reaches an unhandled state.

Expected Behavior

  • After a successful upload, the cleanup process should correctly remove the uploaded file.
  • The upload state should remain consistent to avoid unexpected behavior on retries.

Environment

  • TUSKit Version: 2.2.0
  • Platform: iOS / macOS

Additional Context

I understand that v2.2.0 is a legacy version, and upgrading is not a quick or easy option for me due to system stability concerns. Logging this issue here first as documentation, while I plan to fork my own version for a fix.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the cleanup failure on TUSKit 2.2.0 and trace the upload cleanup flow after a successful upload, including currentUploads and createOrResume. Done means a failed file deletion cannot leave a stale file and an unhandled retry state that permanently hangs the upload.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
desktop, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.