From 3efff25fd8c78cdd699f0c8ba888e10678aea20d Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:54:32 +0900 Subject: [PATCH] fixup --- lib/api/readable.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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