๐Ÿ› BUG: Doing fetch requests in a Worker...

Hi, I have updated my workers and they are using 2.8.1 and now, when I do a env.SERVICE.fetch(request.clone()) it stalls with a " TypeError: Cannot construct a Request with a Request object that has already been used." And it was working before, both in local and deployed in CF. Could it be related to this issue https://github.com/cloudflare/wrangler2/issues/2589 ?
GitHub
๐Ÿ› BUG: Doing fetch requests in a Worker that is invoked from Servic...
Which Cloudflare product(s) does this pertain to? Pages What version of Wrangler are you using? 2.8.0 What operating system are you using? MacOS Describe the Bug Bound Worker This Worker is called ...
4 Replies
Eusebio Trigo
Eusebio TrigoOPโ€ข2y ago
I'm using a "api-gateway"-like code:
const { pathname } = new URL(request.url);
if (pathname.startsWith("/api/config")) {
console.log(`Path ${pathname} requested. - Configuration`)
return await env.configuration.fetch(request.clone());
}
const { pathname } = new URL(request.url);
if (pathname.startsWith("/api/config")) {
console.log(`Path ${pathname} requested. - Configuration`)
return await env.configuration.fetch(request.clone());
}
Eusebio Trigo
Eusebio TrigoOPโ€ข2y ago
About Service bindings ยท Cloudflare Workers docs
Service bindings are an API that facilitate Worker-to-Worker communication via explicit bindings defined in your configuration.
Eusebio Trigo
Eusebio TrigoOPโ€ข2y ago
The Cloudflare Blog
Service Bindings are generally available, with efficient pricing
Service bindings are an API that facilitate Worker-to-Worker communication. You can invoke other Workers directly from your code; making it possible to communicate with shared services. Weโ€™ll also make it cost-efficient to run multiple Workers
Eusebio Trigo
Eusebio TrigoOPโ€ข2y ago
Oh, I will need to wait till there is a new version given https://github.com/cloudflare/wrangler2/pull/2597 was added after the 2.8.1 release cut.
GitHub
fix: do not crash in wrangler dev when passing a request object to ...
What this PR solves / how to test: This reverts and fixes the changes in #1769 which does not support creating requests from requests whose bodies have already been consumed. Fixes #2562 To test y...
Want results from more Discord servers?
Add your server