Use a body stream for worker requests#268
Conversation
|
@augustoccesar - noticed this when debugging some performance problems, WDYT? |
Yeah, this makes a lot of sense. I will take a look if this re-introduces the issue that we were having with the body. If it does, I think we are probably better just reverting #263 to rely on the The issue was the "misunderstanding" if there was a body to process or not for non-standard requests. I'm not sure if the issue was with |
|
Yeah, this brings back the issue that we were trying to solve with #263 😞 I will investigate here if can get both things working! |
|
For context: the issue is that when doing Granted, DELETE requests shouldn't really have bodies, but we do have some "non-conforming" endpoints at the moment. Funny enough, it does not happen if running the worker locally, only once it is deployed to Cloudflare. |
### Description On #263 we changed the conversion of the request from the internal try_into from workers-rs for a manual one to be able to proxy DELETE requests with body. This caused the performance issues reported and with a proposed fix on #268. The changes on #268 however re-introduced the original issue that #263 was attempting to fix, as in it's core, it is what the `try_into` does. As a middle ground, this PR proposes a workaround for the DELETE with body without compromising the performance of other requests.
### Description On #263 we changed the conversion of the request from the internal try_into from workers-rs for a manual one to be able to proxy DELETE requests with body. This caused the performance issues reported and with a proposed fix on #268. The changes on #268 however re-introduced the original issue that #263 was attempting to fix, as in it's core, it is what the `try_into` does. As a middle ground, this PR proposes a workaround for the DELETE with body without compromising the performance of other requests.
|
Yeah @augustoccesar that's what I was going to suggest - even though it's non standard, my understanding is that it's not expressly prohibited? I would even leave it there, not even try to remove it if that works. |
Yeah, it isn't prohibited, but seems discouraged and that some services might just reject the request.
I think we will go with reverting it (#270). For our internal case, it got fixed (changed the endpoint) today, so there isn't really the need for the workaround from our perspective. This would go back to letting the conversion be handled by the workers-rs. Then if is worth bringing up that this should be valid, maybe we open an issue there. |
|
The changes where we started to read the entire body has now been reverted 💪 |
Reading the entire request body to memory as a string is less efficient as being able to use stream primitives. This should increase performance of large request bodies for example file uploads.