Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchResponse does not set the urlList #690

Open
mikicho opened this issue Dec 13, 2024 · 1 comment · May be fixed by #695
Open

FetchResponse does not set the urlList #690

mikicho opened this issue Dec 13, 2024 · 1 comment · May be fixed by #695

Comments

@mikicho
Copy link
Contributor

mikicho commented Dec 13, 2024

Found in nock/nock#2821

const { FetchInterceptor } = require('@mswjs/interceptors/fetch');
const interceptor = new FetchInterceptor();

(async () => {
  interceptor.on('request', ({ controller}) => {
    controller.responseWith(new Response('Hello, world!'))
  })
  // interceptor.apply()

  const response = await fetch('http://example.com')

  // When interceptor disabled
  console.log(response.url) // http://example.com
  console.log(response.clone().url) // http://example.com
  
  // When interceptor applied
  console.log(response.url) // http://example.com
  console.log(response.clone().url) // print empty string
})()

I think it happens because setUrl does not push the URL into the urlList, and therefore does not get cloned.

@mikicho
Copy link
Contributor Author

mikicho commented Dec 13, 2024

@kettanaito I think I can solve this one, but I'm currently deep into cleaning up nock from all the interception logic. so if you don't reach this one while I'm finished, I'll fix it.

wagagaha added a commit to wagagaha/interceptors that referenced this issue Dec 27, 2024
@kettanaito kettanaito linked a pull request Jan 2, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant