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

Possible memory leak #87

Closed
artyom-kurnikov opened this issue Feb 4, 2021 · 3 comments
Closed

Possible memory leak #87

artyom-kurnikov opened this issue Feb 4, 2021 · 3 comments

Comments

@artyom-kurnikov
Copy link

Seems like cross-fetch has a memory leak. Tested in the browser (Google Chrome, 88). The issue is reproduced by simple script (ignore CORS error, it behaves the same when request is resolved) which fires requests in interval:

setInterval(() => {
  fetch('https://google.com')
    .then(console.log, console.log)
}, 250)

After profiling around 1 minute, we can see that event listeners are constantly growing:

image

While they are fine with native fetch:

image

@lquixada
Copy link
Owner

lquixada commented Feb 4, 2021

hey @tigger9flow ! thanks for reporting that. In the browser, cross-fetch is just a wrapper around whatwg-fetch. Can you check if that is happening there as well?

Here's some code to help:

<script>
  // Delete native fetch api to force the polyfill installation
  delete window.fetch
  delete window.Request
  delete window.Response
  delete window.Headers
</script>
<script src="https://unpkg.com/whatwg-fetch@3.5.0/dist/fetch.umd.js"></script>

If it does, please report the issue on https://github.com/github/fetch/issues. Otherwise, please let me know so I can take a look.

@artyom-kurnikov
Copy link
Author

Hey, @lquixada! You're totally right, it's reproduced in whatwg-fetch as well. Sorry for bothering you, I just haven't managed to find the dependency of browser-specific implementation of fetch. Duplicated the issue in whatwg-fetch repo. Thank you! :)

@lquixada
Copy link
Owner

lquixada commented Feb 5, 2021

no worries @tigger9flow ! happy to help! thanks for reporting the issue on whatwg-fetch!

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

No branches or pull requests

2 participants