Skip to content

Commit 03bdbf6

Browse files
mcollinacrysmags
authored andcommitted
Fix fetch in node v20.6.0 (nodejs#2251)
1 parent 6840ae0 commit 03bdbf6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/core/util.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,20 @@ function getSocketInfo (socket) {
355355
}
356356
}
357357

358+
async function * convertIterableToBuffer (iterable) {
359+
for await (const chunk of iterable) {
360+
yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
361+
}
362+
}
363+
358364
let ReadableStream
359365
function ReadableStreamFrom (iterable) {
360366
if (!ReadableStream) {
361367
ReadableStream = require('stream/web').ReadableStream
362368
}
363369

364370
if (ReadableStream.from) {
365-
// https://github.com/whatwg/streams/pull/1083
366-
return ReadableStream.from(iterable)
371+
return ReadableStream.from(convertIterableToBuffer(iterable))
367372
}
368373

369374
let iterator

0 commit comments

Comments
 (0)