Skip to content

S3 Store stopped after uploading first chunk #686

Closed

Description

@iamsahebgiri

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Steps to reproduce

Size of the video file on disk is 158MB, but minio shows ~70MB (that's my part size).
image

// config/tus.js
const path = require("path");
const { Server, EVENTS } = require("@tus/server");
const { S3Store } = require("@tus/s3-store");

const env = require("./env");
const { s3ClientConfig } = require("./s3");

const s3Store = new S3Store({
  partSize: 80 * 1024 * 1024, // each uploaded part will have ~80MiB,
  s3ClientConfig: {
    ...s3ClientConfig,
    bucket: env.UPLOAD_BUCKET,
  },
});

const fileStore = new FileStore({
  directory: "./uploads",
});

const tusServer = new Server({
  path: "/upload",
  datastore: s3Store,
});

tusServer.on(EVENTS.EVENT_UPLOAD_COMPLETE, (event) => {
  console.log(
    `[${new Date().toLocaleTimeString()}] [EVENT HOOK] Upload complete for file ${
      event.file.id
    }`
  );
});

module.exports = tusServer;
// app.js
const express = require("express");
const cors  = require("cors");
const env = require("./config/env");
const { initializeBuckets } = require("./config/s3");
const tusServer = require("./config/tus");

const app = express();
const uploadApp = express();

const PORT = env.PORT;

// app.use(express.static("public"));

app.use(cors());
uploadApp.all("*", tusServer.handle.bind(tusServer));
app.use("/upload", uploadApp);

async function startServer() {
  await initializeBuckets();

  app.listen(PORT, () => {
    console.log(`Server running on  http://localhost:${PORT}`);
  });
}

startServer();

Frontend code

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Veed - Video transcoding pipeline</title>
    <link
      href="https://releases.transloadit.com/uppy/v4.7.0/uppy.min.css"
      rel="stylesheet"
    />
    <style>
      .uppy-size--md .uppy-Dashboard-AddFiles-info {
        display: none;
      }
    </style>
  </head>
  <body>
    <h1>Veed - Video transcoding pipeline</h1>
    <noscript>You need JavaScript enabled for this example to work.</noscript>
    <button id="uppyModalOpener">Open Modal</button>
    <script type="module">
      import {
        Uppy,
        Dashboard,
        Webcam,
        Tus,
      } from "https://releases.transloadit.com/uppy/v4.8.0/uppy.min.mjs";

      const uppy = new Uppy({
        debug: true,
        autoProceed: false,
        restrictions: {
          maxFileSize: 1024 * 1024 * 1024, // 1GB
          allowedFileTypes: ["video/*"],
        },
      })
        .use(Dashboard, { trigger: "#uppyModalOpener" })
        .use(Webcam, { target: Dashboard })
        // .use(Tus, { endpoint: "https://tusd.tusdemo.net/files/" });
        .use(Tus, { endpoint: "http://localhost:8001/upload" });

      uppy.on("success", (fileCount) => {
        console.log(`${fileCount} files uploaded`);
      });
    </script>
  </body>
</html>

Expected behavior

It should ideally upload the entire file.

Actual behavior

Uploading just the first chunk of the video when s3 store is used. This works fine if s3 store is replaced with file store.

Activity

  1. Murderlon commented on Dec 17, 2024

    @Murderlon
    Collaborator

    Hi, can you remove your partSize and test it the exact same way again? Wondering if it does work for you then.

  2. iamsahebgiri commented on Dec 18, 2024

    @iamsahebgiri
    Author

    Tried that as well but that didn't help though, can you point me to an example with minio?

  3. Murderlon commented on Dec 19, 2024

    @Murderlon
    Collaborator

    There is no such example. However Supabase is using @tus/server and @tus/s3-store in production at a massive global scale and reported no such issues. So wondering if this is related to minio as your integration code looks fine 🤔

  4. iamsahebgiri commented on Dec 19, 2024

    @iamsahebgiri
    Author

    This possibly could be minio, but I have tried using tusd binary, which seems to be working fine even with minio.

  5. fenos commented on Dec 19, 2024

    @fenos
    Collaborator

    @iamsahebgiri can you create a repo that reproduces the issuee, please
    That would help a lot

  6. iamsahebgiri commented on Dec 19, 2024

    @iamsahebgiri
    Author

    Hi @fenos, here is the repo which reproduce the issue, https://github.com/iamsahebgiri/tus-minio-repro

    Hope that helps.

  7. fenos commented on Dec 19, 2024

    @fenos
    Collaborator

    Hi @iamsahebgiri i can confirm that there is a pretty nasty bug 😄
    Will raise a PR shortly

  8. fenos commented on Dec 19, 2024

    @fenos
    Collaborator

    It was a regression on this commit:
    227ae81#diff-fecfad9cf273825148c4be6b30379a6331608acd8b71f5acd9fc60c2286be034L365-R370

    Currently the partNumber is never increased, resulting in uploading each chunk always on the part number 2

  9. juliusrennerbosch commented on Jan 8, 2025

    @juliusrennerbosch

    I was having the same issue and can confirm, that that the latest version (1.6.2) fixes the problem. Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions