cloudflare / workers-sdk

โ›…๏ธ Home to Wrangler, the CLI for Cloudflare Workersยฎ
https://developers.cloudflare.com/workers/
Apache License 2.0
2.58k stars 663 forks source link

๐Ÿ› BUG: request.body hangs for long time (5 minutes) when uploading files of small size (~3-5MB) #4393

Closed AAAstorga closed 9 months ago

AAAstorga commented 10 months ago

Which Cloudflare product(s) does this pertain to?

R2, Workers Runtime, Wrangler core

What version(s) of the tool(s) are you using?

3.15.0 [Wrangler]

What version of Node are you using?

v18.12.1

What operating system are you using?

Mac

Describe the Bug

I am trying to upload photos from the browser to my cloudflare worker. I then store these files in R2.

The rough code is:

await env.R2_BUCKET.put(key, request.body, {
          httpMetadata: {
            contentType,
          },
        }) ;

Local development with Wrangler: When the body is of size ~500KB or less it works fine and as expected. When the body is >~500KB (like a 3.9MB photo), it will hang on this line for ~5 minutes before completing.

I uploaded my worker to Cloudflare and then tried again and it works as expected and has no issues uploading a 3.9MB photo, so it seems like it is just with local development. I am not sure what is causing this issue, but it makes developing with R2 locally more difficult.

Let me know if I can provide any other information.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

mrbbot commented 10 months ago

Hey! ๐Ÿ‘‹ Thanks for raising this issue! I'm unable to reproduce this locally with a 3.1MB HEIF photo, the following script...

export default {
  async fetch(request, env, ctx) {
    await env.BUCKET.put("key", request.body, {
      httpMetadata: {
        contentType: request.headers.get("Content-Type") ?? undefined
      }
    });
    return new Response("uploaded");
  }
};

...npx wrangler@3.15.0 dev, and curl http://127.0.0.1:8787 --data-binary @./big-image.heic. ๐Ÿ™

Would you be able to share a minimal reproduction repo?

AAAstorga commented 10 months ago

Hey! ๐Ÿ‘‹ Thanks for raising this issue! I'm unable to reproduce this locally with a 3.1MB HEIF photo, the following script...


export default {

  async fetch(request, env, ctx) {

    await env.BUCKET.put("key", request.body, {

      httpMetadata: {

        contentType: request.headers.get("Content-Type") ?? undefined

      }

    });

    return new Response("uploaded");

  }

};

...npx wrangler@3.15.0 dev, and curl http://127.0.0.1:8787 --data-binary @./big-image.heic. ๐Ÿ™

Would you be able to share a minimal reproduction repo?

Interesting. Let me try to put together a Repro. Thanks for taking a look.

lrapoport-cf commented 9 months ago

hi @AAAstorga ! we haven't heard from you in a while, so weโ€™re going to close this issue for now. If this is still a problem, please feel free to open a new issue referencing this one. please be sure to include an updated summary, repro, and any other additional relevant details and we will revisit and investigate further. thanks!