signalapp / tus-server

An implementation of the TUS server protocol for resumable uploads
GNU Affero General Public License v3.0
30 stars 9 forks source link

Buffering issue #1

Open thedentist8 opened 8 months ago

thedentist8 commented 8 months ago

Thanks for sharing this repo. I managed to get it up and running, however I'm facing an issue.

When a request is sent to Cloudflare, it first buffers the entire request body before it sends it to the worker for processing. For instance, if I try to upload a 100MB file, and the connection interrupts after 90MB is uploaded, then nothing will be stored in the R2 bucket as the request hasn't been processed by the Worker at all (it was just buffered by CF). Wondering if you've found a solution around this?

Thanks!

thedentist8 commented 8 months ago

@ravi-signal wondering if you have any thoughts on this.

stupidloud commented 7 months ago

Thanks for sharing this repo. I managed to get it up and running, however I'm facing an issue.

When a request is sent to Cloudflare, it first buffers the entire request body before it sends it to the worker for processing. For instance, if I try to upload a 100MB file, and the connection interrupts after 90MB is uploaded, then nothing will be stored in the R2 bucket as the request hasn't been processed by the Worker at all (it was just buffered by CF). Wondering if you've found a solution around this?

Thanks!

That might because your worker had triggered the memory limit which is 128Mb. The R2 documentary said you can use Streams API to get over this limit, but I don't know how to write this in code. (referred to: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/#4-access-your-r2-bucket-from-your-worker) The other way is to set a chunksize option for your tus-client, below 100Mb. It works but the upload process will hang for a few seconds in each chunked subrequests, while it will bring down the upload speed significantly.