Skip to content

Commit 0dee09d

Browse files
authored
fetch: use ReadableStreamTee for cloning streams (#5517)
1 parent cb4c2f1 commit 0dee09d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/web/fetch/body.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const { serializeAMimeType } = require('./data-url')
1616
const { multipartFormDataParser } = require('./formdata-parser')
1717
const { parseJSONFromBytes } = require('../infra')
1818
const { utf8DecodeBytes } = require('../../encoding')
19+
const { ReadableStreamTee } = require('node:stream/web')
1920

2021
const textEncoder = new TextEncoder()
2122
function noop () {}
@@ -279,7 +280,7 @@ function cloneBody (body) {
279280
// https://fetch.spec.whatwg.org/#concept-body-clone
280281

281282
// 1. Let « out1, out2 » be the result of teeing body’s stream.
282-
const { 0: out1, 1: out2 } = body.stream.tee()
283+
const { 0: out1, 1: out2 } = ReadableStreamTee?.(body.stream, true) ?? body.stream.tee()
283284

284285
// 2. Set body’s stream to out1.
285286
body.stream = out1

0 commit comments

Comments
 (0)