Giter Site home page Giter Site logo

Comments (3)

Acconut avatar Acconut commented on May 24, 2024

Thank you for bringing this up and describing the problem in great detail. While I understand the problem, I think that such a concurrency limit should rather be implemented by the user. As you mentioned, one tus upload has a maximum of 1 concurrent request (unless you are using the parallelUploads option). Therefore, one can control the number concurrent requests by managing how many uploads are started in parallel. Such a limit can easily be implemented using a queue or semaphore. The advantage of implementing a request limit outside of tus-js-client is that the user receives more feedback about the upload's state. For example, when an upload is not started because the concurrency limit is reached, the UI can be updated to reflect this fact. When we implement a limit in tus-js-client the user would just see an upload that is not progressing.

Furthermore, if you actually want to limit the number of requests (and not the number of uploads), you can implement this right now using the onBeforeRequest option. It can also return a Promise and by resolving that Promise whenever the concurrency limit allows another request, you can implement the desired functionality.

All in all, I think that there are better alternatives than having this functionality in tus-js-client.

from tus-js-client.

mtt-artis avatar mtt-artis commented on May 24, 2024

hi @Acconut,
thanks for the reply.

As you mentioned, one tus upload has a maximum of 1 concurrent request (unless you are using the parallelUploads option).

I think I was fooled by the dev tools where I can see 4 pending requests at once for one upload.

const upload = new Upload(file, {
  endpoint: "/api/files",
  chunkSize: 1_000_000,
  retryDelays: [0, 1000, 3000, 5000],
  metadata: {
    filename: file.name,
    filetype: file.type,
    lastModified: file.lastModified.toString(),
  },
};
upload.start();

image



It can also return a Promise and by resolving that Promise whenever the concurrency limit allows another request.

do you have a repository with such functionality to show me?

from tus-js-client.

Acconut avatar Acconut commented on May 24, 2024

I think I was fooled by the dev tools where I can see 4 pending requests at once for one upload.

If you call upload.start() once then there should only ever be one PATCH request. Any other behavior would indicate a bug. Can you reproduce the multiple PATCH requests? Do you call start multiple time?

do you have a repository with such functionality to show me?

No, unfortunately I do not have an example showcasing this.

from tus-js-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.