Repro:
import { Readable } from 'node:stream';
export default {
async fetch() {
const rNode = new Request('https://example.com', {
method: 'POST',
body: Readable.from([...'node']),
});
for await (const l of rNode.body!) {
console.log(l);
}
const rWeb = new Request('https://example.com', {
method: 'POST',
body: ReadableStream.from([...'web']),
});
for await (const l of rWeb.body!) {
console.log(l);
}
return new Response('done');
},
};
Logs:
Uint8Array(15) [
91, 111, 98, 106, 101,
99, 116, 32, 79, 98,
106, 101, 99, 116, 93
] // "[object Object]"
w
e
b
Node (/undici) have extra support for AsyncIterable<Uint8Array>, Iterable<Uint8Array>, and null for BodyInit
Response can also be initialized with a BodyInit, i.e. return new Response(bodyInit); so we should also update the response in the same way
Repro:
Logs:
Node (/undici) have extra support for
AsyncIterable<Uint8Array>,Iterable<Uint8Array>, andnullforBodyInitResponsecan also be initialized with aBodyInit, i.e.return new Response(bodyInit);so we should also update the response in the same way