-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: Your worker called response.clone(), but did not read the body of both clones #3259
Comments
|
I do not have any |
Are you using any frameworks? I'm using Remix, and see the same thing on any POST requests with bodies, and having a hard time tracking down where the clone is happening... Also, it looks like this will happen when cloning any ReadableStream (without reading both sides), I believe, based on where it originates in workerd: https://github.com/cloudflare/workerd/blob/ed4c67df1b231270410a72cb0161c203e55b0bb6/src/workerd/api/streams/internal.c%2B%2B#L291-L298 |
@zwily no, I do not use any frameworks.
that's basically it |
Getting this nuisance message with this minimal example:
Every For what it's worth, adding some code that uses |
Seeing the same warning when using D1 with Wrangler v3 |
Same... |
same, hop the train! |
Same. I can confirm that I'm not cloning anywhere, seems to reproduce with just adding a pages function. Seems like this might be a bug in the pages functions logic? Edit: is it maybe the pages asset server? https://github.com/cloudflare/workers-sdk/blob/main/packages/pages-shared/asset-server/handler.ts#L340 |
Hi, I'm getting the same warning, I'm using wrangler@3.0.1 os: Ubuntu 23.04 |
any update on this @KianNH ? |
I think that might be the cause |
Having the same issue, using simple hono router, with v3 and D1 on MacOS. |
@EliBates you can upgrade the wrangler sdk to @3.1.0 |
Was it addressed? |
Nothing changed with regards to this in wrangler 3.1.0 |
I'm on 3.1.0 and still the same issue in a bare bones project |
I'm seeing this as well with 3.1.1 and pages functions. Not cloning the response anywhere. The following function runs after a couple layers of export const onRequestPost = async ({ data }) => {
if (!data.userProfile.id) throw new Error('UserProfile ID is null!');
const apiKey = await data.db
.insert(userApiKeys)
.values({
ownerId: data.userProfile.id,
})
.returning()
.get();
return new Response(JSON.stringify(apiKey), {
headers: { 'Content-Type': 'application/json' },
status: 200,
});
}; This error only seems to be thrown on a POST request, GET requests seem unaffected. It also appears this message is generated at each level of _middleware that your request passes through. Simply reading the request body at each layer will squelch one instance of the message. Something as simple as the following is enough: const noopBody = request.json(); I was able to remove most of the recurrent message, but not all by using this method. Definitely seems like something is off here. |
Im having the same problem here since Remix 18.1 and can confirm that this problem persists on Remix 2.0. Any update? |
I am having the same issue: Do any of you having the issue have these in node_modules? |
I am having the same problem.
It is doubtful whether it can be applied to actual service in this state. Has anyone solved it? |
Nobody fixed that yet? |
I'm having the same issue, no matter if I clone or .tee() the body. |
I'm getting five copies of this error on every call to a resource-only Remix action:
Edit: Found this Remix issue. |
I'm using Astro though that should not matter when the request gets into the functions context. Using the property It has to be a Pages functions bug of some sort. I will probably test creating a Worker separate from Pages and use bindings to forward the request to the Worker and see what happens. I'll report back but it will have to be later today or tomorrow. |
We just tried wrangler 3.7.0 and can still observe this warning. @GregBrimble @JacobMGEvans do you need anything from the community in order to be able to tackle this? |
I think the lines below might be causing the problem, but I'm not sure.
|
this issue seems to have been fixed in wrangler version |
Closing as this behaviour was fixed as of wrangler version |
Hi @CarmenPopoviciu, I am running wrangler 3.18.0 and I am still having this issue. I have implemented code similar to this example: https://developers.cloudflare.com/workers/examples/cache-post-request/ Specifically this line is causing the warnings:
However, removing the Let me know if you need more information! |
Ran into a similar issue with Remix & Cloudflare Pages (wrangler@3.22.3) where your proposed fix works. If we can reopen this issue and you need anything, I'll be available to assist.
Remix has a pre-existing open issue @ remix-run/remix#7032
|
Looks like this error reappeared in version 3.22.3 |
same as @saidelimam, i'm on 3.22.4, at no point do i call figured i should leave a comment to validate that the issue is still happening, or to maybe discover my own mistake. |
Can confirm, same issue in wrangler 3.22.3 / 3.22.4 |
If I roll back to |
Can this issue still be re-opened or do we need to create a new issue? @CarmenPopoviciu |
I can confirm it's still happening with Wrangler v3.23.0 and the "Hello world" example from the Pages Functions docs. |
I can confirm the downgrading wrangler to |
@lrapoport-cf looks like this is a regression per your comment here, you mentioned we should feel free to add the 'regression' label when appropriate ourselves, however, non-CF employees don't seem to have those permissions (probably a wise decision). so, tagging you here for visibility/so the tag can get added |
Here's a simple fix: https://gist.github.com/russelldavis/6b1a1bf15898655ec18037bd737d075d If you have middleware that reads the body of the request, you'll need to update it to call It'd be great if cloudflare would fix this (it's a breaking change, but that's what major versions are for), but in the meanwhile, you can fix this in your own project by applying the patch above using patch-package or pnpm patch. |
Which Cloudflare product(s) does this pertain to?
Wrangler
What version of
Wrangler
are you using?3.0.0
What operating system are you using?
Windows
Describe the Bug
After upgrading to 3.0.0 new message started appearing in the console:
However, it does not say which exactly part of code is to blame.
I scanned my code and I do not call
response.clone()
directly anywhere, also, I have multiple levels of functions, making it hard to pin-point where the issue is and whether the issue is there at all.The text was updated successfully, but these errors were encountered: