Skip to content

Native fetch response clone misses url #2821

@slagiewka

Description

@slagiewka

Please avoid duplicates

Reproducible test case

Can't import @beta or @14.0.0-beta.19 in RunKit, sorry :(

Nock Version

beta, 14.0.0-beta.19

Node Version

22 and 23

TypeScript Version

No response

What happened?

  1. Setup a simple nock (tested directly in project on branch beta)
  2. Use native fetch with simple GET
  3. Clone the response
  4. URL should be set.
describe('Native Fetch', () => {
  it('clones all', async () => {
    const scope = nock('http://example.test').get('/').reply()

    const response = await fetch('http://example.test/')
    const clonedResponse = response.clone();

    expect(clonedResponse).to.equal(response);
    scope.done()
  })
}

results in
image

I'm not sure how nock handles things exactly under the hood whether it offloads stuff to some other library for it.

Testing the same directly in node results in url being set correctly for both original and cloned response.

I found this when trying to make @apollo/datasource-rest use native fetch/undici.fetch instead of node-fetch.

Would you be interested in contributing a fix?

  • yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions