diff --git a/lib/api/readable.js b/lib/api/readable.js index ed530b1eb81..50a23f36d8a 100644 --- a/lib/api/readable.js +++ b/lib/api/readable.js @@ -299,9 +299,18 @@ function consumeEnd (consume) { case 'json': resolve(JSON.parse(utf8DecodeBytes(Buffer.concat(body, length)))) break - case 'arrayBuffer': - resolve(Buffer.concat(body, length).buffer) + case 'arrayBuffer': { + const dst = new Uint8Array(length) + + let pos = 0 + for (const buf of body) { + dst.set(buf, pos) + pos += buf.byteLength + } + + resolve(dst.buffer) break + } case 'blob': resolve(new (Blob ??= require('buffer').Blob)(body, { type: stream[kContentType] })) break