Skip to content

Fix cancellation of uploads#48

Merged
Floriszenz merged 4 commits intomainfrom
fix-aborting-of-uploads
Mar 12, 2026
Merged

Fix cancellation of uploads#48
Floriszenz merged 4 commits intomainfrom
fix-aborting-of-uploads

Conversation

@UniquePanda
Copy link

@UniquePanda UniquePanda commented Mar 12, 2026

Immediately after releasing version 5.0.0 we noticed that cancelling uploads was broken.
This is due to race conditions between the previous way of cancelling uploads and the new concept of upload tasks. Previously the code only iterated over all files and aborted them without "notifying" any other code parts about the cancellation. This means any upload task simply picked up the next chunk when its current one was aborted and the upload continued as before.

Now, a boolean is set that will be checked before an upload task picks up a new chunk. In case this bool is true, no new chunk will be uploaded. Additionally, only the files that were currently being uploaded by any upload task are aborted, because we know that no other file is currently uploading.
This also fixes a problem that existed prior to version 5: With many files, it was not really possible to cancel the upload, because the browser would hang, asking the user multiple times if they want to wait or leave the side (because the iteration over all files and chunks took so long). Now this operation should be pretty much instant.
Only one caveat: I kept the iteration over all chunks of a file that is being aborted. So for really really big files it will probably still take some time, but I think it's still better than before, certainly not worse.
I kept that in because the code when aborting a file upload is doing some additional stuff and I wanted to have this fix asap, so I only touched the code in resumable.ts.

Note:
The readme always said that the list of files is emptied when the upload is cancelled. This was not the case before. The files weren't removed from the list, but all of their chunks were removed. I fixed this.
Technically that's a breaking change, although the behavior was broken before. So we should release this fix as version 6.0.0. 😄

@UniquePanda UniquePanda self-assigned this Mar 12, 2026
@UniquePanda UniquePanda changed the title Remove obsolete uncompletedFileCategories Fix cancellation of uploads Mar 12, 2026
@UniquePanda UniquePanda added the bug Something isn't working label Mar 12, 2026
UniquePanda added a commit that referenced this pull request Mar 12, 2026
@UniquePanda UniquePanda marked this pull request as ready for review March 12, 2026 08:18
@UniquePanda UniquePanda requested a review from Floriszenz March 12, 2026 08:19
@UniquePanda UniquePanda force-pushed the fix-aborting-of-uploads branch from bb90da9 to 4e05207 Compare March 12, 2026 08:23
@Floriszenz Floriszenz merged commit 35c8681 into main Mar 12, 2026
@Floriszenz Floriszenz deleted the fix-aborting-of-uploads branch March 12, 2026 09:38
@UniquePanda UniquePanda mentioned this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants