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

log when tus uploaded size differs #5647

Merged
merged 1 commit into from
Feb 17, 2025
Merged

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Feb 14, 2025

for debugging purposes

Copy link
Contributor

Diff output files
diff --git a/packages/@uppy/companion/lib/server/Uploader.js b/packages/@uppy/companion/lib/server/Uploader.js
index ee2d553..bc239e6 100644
--- a/packages/@uppy/companion/lib/server/Uploader.js
+++ b/packages/@uppy/companion/lib/server/Uploader.js
@@ -448,7 +448,7 @@ class Uploader {
     // chunkSize needs to be a finite value if the stream is not a file stream (fs.createReadStream)
     // https://github.com/tus/tus-js-client/blob/4479b78032937ac14da9b0542e489ac6fe7e0bc7/lib/node/fileReader.js#L50
     const chunkSize = this.options.chunkSize || (isFileStream ? Infinity : 50e6);
-    return new Promise((resolve, reject) => {
+    const tusRet = await new Promise((resolve, reject) => {
       const tusOptions = {
         endpoint: this.options.endpoint,
         uploadUrl: this.options.uploadUrl,
@@ -503,6 +503,15 @@ class Uploader {
       this.tus = new tus.Upload(stream, tusOptions);
       this.tus.start();
     });
+    // @ts-ignore
+    if (this.size != null && this.tus._size !== this.size) {
+      // @ts-ignore
+      logger.warn(
+        `Tus uploaded size ${this.tus._size} different from reported URL size ${this.size}`,
+        "upload.tus.mismatch.error",
+      );
+    }
+    return tusRet;
   }
   async #uploadMultipart(stream) {
     if (!this.options.endpoint) {

@mifi mifi merged commit ead58be into main Feb 17, 2025
19 checks passed
@mifi mifi deleted the log-when-tus-uploaded-size-differs branch February 17, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants