Skip to content

Chained calls to response.clone() do not persist the high water mark #1161

@davesidious

Description

@davesidious

When calling .clone() on a Response instance, the highWaterMark is persisted in the cloned body, but not in the cloned Request itself. This means that cloning the clone results in a lost highWaterMark.

Reproduction

Steps to reproduce the behavior:

const res = await fetch('https://httpbin.org/bytes/200', {
  highWaterMark: 1024 * 1024
})

console.log(res.highWaterMark) // Is set correctly

const cloneOne = res.clone()

console.log(cloneOne.highWaterMark) // Is undefined

const cloneTwo = cloneOne.clone()

console.log(cloneTwo.highWaterMark) // Is undefined

Expected behavior

const res = await fetch('https://httpbin.org/bytes/200', {
  highWaterMark: 1024 * 1024
})

console.log(res.highWaterMark) // Is set correctly

const cloneOne = res.clone()

console.log(cloneOne.highWaterMark) // Is set correctly

const cloneTwo = cloneOne.clone()

console.log(cloneTwo.highWaterMark) // Is set correctly
software version
node-fetch 3.0.0-beta.9
node 14.16.1
npm 6.14.12
Operating System Ubuntu 20.04.2 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions