workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: Warning about "redundant `response.clone()`" even if you call `request.clone()`

Open colecrouter opened this issue 2 years ago • 1 comments

What version of Wrangler are you using?

2.0.23

What operating system are you using?

Windows

Describe the Bug

If you have redundant calls to response.clone() on non-local wrangler dev, you normally get this message:

Your worker called response.clone(), but did not read the body of both clones. This is wasteful, as it forces the system to buffer the entire response body in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the response headers and metadata (e.g. in order to be able to modify them), use new Response(response.body, response) instead.

However, you get this same message if you have redundant calls to request.clone() as well. Ideally when this happens, it should say:

- Your worker called response.clone(), but...
+ Your worker called request.clone(), but...

–to be less confusing. Or at least, a more generalized message could be used:

Your worker called either response.clone() or request.clone(), but...

Since I couldn't find this string in the Wrangler source, and it doesn't occur when using Miniflare, I'd imagine it exists in another codebase.

colecrouter avatar Jul 29 '22 20:07 colecrouter

You're right this doesn't seem like it exists in wrangler, we'll take a look internally!

jspspike avatar Sep 06 '22 16:09 jspspike