The following code:
export default {
async fetch(request, env, ctx): Promise<Response> {
let cr = new Request(new URL('http://localhost/test'), { method: 'POST', body: createReadableStreamFromString('Hello stream'), duplex: "half" });
let cr2 = cr.clone();
const text1 = await cr.text();
const text2 = await cr2.text();
console.log({text1, text2});
return new Response(`jkljlkjlk`);
},
} satisfies ExportedHandler<Env>;
function createReadableStreamFromString(str) {
const encoder = new TextEncoder();
const encodedData = encoder.encode(str);
return new ReadableStream({
start(controller) {
// Enqueue the data and close the stream
controller.enqueue(encodedData);
controller.close();
}
});
}
would log
[wrangler:info] GET /favicon.ico 200 OK (3ms)
{ text1: 'Hello stream', text2: '' }
When the same code is executed in the browser or in Node, the output is:
{ text1: 'Hello stream', text2: 'Hello stream' }
Extra info:
"compatibility_flags": ["nodejs_compat"],
"compatibility_date": "2025-09-15",
wrangler 4.40 -> workerd 1.20250924.0
This was originally reported by a customer using Open Next, see opennextjs/opennextjs-cloudflare#859
The following code:
would log
When the same code is executed in the browser or in Node, the output is:
Extra info:
wrangler 4.40 -> workerd 1.20250924.0
This was originally reported by a customer using Open Next, see opennextjs/opennextjs-cloudflare#859