Don't take the queue down when cancelling a transforming file - #2379
Merged
Merged
Conversation
`transformFile` is asynchronous, and a file is already UPLOADING while it runs. For that window it has no `xhr`, which broke `cancelUpload` twice over. `_getFilesWithXhr(file.xhr)` was called with `undefined` and matched every file whose `xhr` was also undefined -- that is, everything still queued. Cancelling one upload set them all to CANCELED and emitted a `canceled` event for each. Group by the request only when there is one; without it the file is its own group. Then, because nothing rechecked the status, the transform callback went on to upload the file the user had just cancelled. Bail out instead when every file in the batch has been cancelled. Refs #2231
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2231.
transformFileis asynchronous — resizing or compressing a large image, or asking a server to presign the upload — andprocessFilehas already set the file toUPLOADINGbefore it runs. For that whole window the file has noxhr, andcancelUploadgot it wrong in two separate ways.The queue gets cancelled too
_getFilesWithXhrfilters onfile.xhr === xhr, so passingundefinedmatches every file whosexhris also undefined — every file still sitting in the queue. Cancelling one upload set them all toCANCELEDand emitted acanceledevent for each. Againstmain:The grouping exists for
uploadMultiple, where several files share one request. With no request there is nobody to share it with, so the group is just the file. That also removes the!—file.xhris genuinely optional here, and the assertion was covering for exactly the case that was broken.And the cancelled file is uploaded anyway
Nothing rechecked the status when the transform came back, so the callback went straight on to
_uploadData. Cancel a file mid-transform and it was still sent — which is the "removes from the dropzone but still sends to the server" in #2231. Againstmain:uploadFilesnow returns early when every file in the batch has been cancelled.Scope
Two tests in
.cancelUpload(), one per half, both failing againstmainas above.One case this deliberately does not solve: with
uploadMultiple, cancelling one file of a batch mid-transform still sends that file's data, because the batch is a single request whose parts are already aligned withfiles. Dropping a member would shift the_getParamName(i)indices the server sees, so it wants its own change. Every file in the batch being cancelled — which is whatcancelUploadproduces once the request exists — is handled.