Skip to content

Commit

Permalink
Fix fetch in node v20.6.0 (#2251)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored Sep 8, 2023
1 parent 932e5f6 commit b95f3e1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,20 @@ function getSocketInfo (socket) {
}
}

async function * convertIterableToBuffer (iterable) {
for await (const chunk of iterable) {
yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
}
}

let ReadableStream
function ReadableStreamFrom (iterable) {
if (!ReadableStream) {
ReadableStream = require('stream/web').ReadableStream
}

if (ReadableStream.from) {
// https://github.com/whatwg/streams/pull/1083
return ReadableStream.from(iterable)
return ReadableStream.from(convertIterableToBuffer(iterable))
}

let iterator
Expand Down

0 comments on commit b95f3e1

Please sign in to comment.