Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/tus: fix event upload-success response.body.xhr #5503

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

ItsOnlyBinary
Copy link
Contributor

this.resetUploaderReferences(file.id) causes the xhr object to be reset to empty XMLHttpRequest

This patch fires the upload-success event before calling this.resetUploaderReferences(file.id)

to test this patch try:

uppy.on('upload-success', (file, response) => {
    const xhr = response.body.xhr;
    console.log('upload-success', xhr.readyState);

    // readyState should be `4` which is the DONE state, before this patch it was always `0`
    // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState 
});

Related: #5444, #5456

@ItsOnlyBinary ItsOnlyBinary changed the title @uppy/tus: fix event upload-success payload.body.xhr @uppy/tus: fix event upload-success response.body.xhr Nov 7, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Diff output files
diff --git a/packages/@uppy/tus/lib/index.js b/packages/@uppy/tus/lib/index.js
index 8ebdeff..8fdf8ed 100644
--- a/packages/@uppy/tus/lib/index.js
+++ b/packages/@uppy/tus/lib/index.js
@@ -233,9 +233,9 @@ function _uploadLocalFile2(file) {
           xhr: payload.lastResponse.getUnderlyingObject(),
         },
       };
+      this.uppy.emit("upload-success", this.uppy.getFile(file.id), uploadResp);
       this.resetUploaderReferences(file.id);
       queuedRequest.done();
-      this.uppy.emit("upload-success", this.uppy.getFile(file.id), uploadResp);
       if (upload.url) {
         const {
           name,

@Murderlon Murderlon merged commit 014f1da into transloadit:main Nov 11, 2024
17 checks passed
@Murderlon
Copy link
Member

Thanks a lot!

github-actions bot added a commit that referenced this pull request Nov 11, 2024
| Package         | Version | Package         | Version |
| --------------- | ------- | --------------- | ------- |
| @uppy/aws-s3    |   4.1.2 | @uppy/tus       |   4.1.4 |
| @uppy/companion |   5.1.4 | uppy            |   4.7.0 |
| @uppy/locales   |   4.3.0 |                 |         |

- @uppy/aws-s3: clarify and warn when incorrect buckets settings are used (Mikael Finstad / #5505)
- @uppy/tus: fix event upload-success response.body.xhr (ItsOnlyBinary / #5503)
- @uppy/companion: Enable CSRF protection in grant (OAuth2) (Mikael Finstad / #5504)
- @uppy/locales: Add ms_MY (Malay) locale (Salimi / #5488)
@ItsOnlyBinary ItsOnlyBinary deleted the upload-success-xhr branch November 11, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants