Skip to content

Commit 9134ee6

Browse files
authored
Add regression test for broken body (nodejs#3346)
Signed-off-by: Matteo Collina <[email protected]>
1 parent e5c242d commit 9134ee6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/fetch/response.js

+15
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ test('constructing a Response with a ReadableStream body', async (t) => {
189189
assert.deepStrictEqual(await response3.json(), JSON.parse(text))
190190
})
191191

192+
await t.test('.arrayBuffer() correctly clones multiple buffers', async () => {
193+
const buffer = Buffer.allocUnsafeSlow(2 * 1024 - 2)
194+
const readable = new ReadableStream({
195+
start (controller) {
196+
for (let i = 0; i < buffer.length; i += 128) {
197+
controller.enqueue(buffer.slice(i, i + 128))
198+
}
199+
controller.close()
200+
}
201+
})
202+
203+
const response = new Response(readable)
204+
assert.deepStrictEqual(await response.arrayBuffer(), buffer.buffer)
205+
})
206+
192207
await t.test('Readable stream with non-Uint8Array chunks', async () => {
193208
const readable = new ReadableStream({
194209
start (controller) {

0 commit comments

Comments
 (0)