cloudflare / cloudflare/workerd
🐛 Bug Report — `new Request(Proxy(request))` fails
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
- Ref issue on Open Next: https://github.com/opennextjs/opennextjs-cloudflare/issues/1144
- Related [Next.js code ](https://github.com/vercel/next.js/blob/84f1e44d4d055ce8326cc96d5bb39eaf8dbba523/packages/next/src/server/route-modules/app-route/module.ts)
- Tested with wrangler 4.86.0 / workerd 20260310
Creating a `new Request` from a proxy fails with `TypeError: Invalid URL: [object Request]`
Repro code on a worker:
```ts
export default {
async fetch(): Promise {
const handler = {
get(_target, prop, _receiver) {
console.log('get', prop);
return Reflect.get(...arguments);
},
};
const proxy = new Proxy(new Request('http://ex.com'), handler);
const clone = new Request(proxy);
console.log(clone.url);
return new Response(`Clone URL: ${clone.url}`);
},
} satisfies ExportedHandler;
```
The output is:
``` plain
get Symbol(Symbol.toPrimitive)
get toString
get Symbol(Symbol.toStringTag)
[wrangler:error] TypeError: Invalid URL: [object Request]
```
The same code:
```ts
const handler = {
get(_target, prop, _receiver) {
console.log('get', prop);
return Reflect.get(...arguments);
},
};
const proxy = new Proxy(new Request('http://ex.com'), handler);
const clone = new Request(proxy);
console.log(clone.url);
```
Works well in Node and generate the following output:
```plain
get Symbol(dispatcher)
get Symbol(state)
get Symbol(signal)
get Symbol(state)
http://ex.com/
```
I believe this issue linked to https://github.com/cloudflare/workerd/pull/5476 and https://github.com/cloudflare/workerd/pull/5711 that implement something that does not match the Node.js behavior.
/cc @jasnell
Contributor guide
Assessment
This issue has not been assessed yet.