Memory leak with responseType: 'text' and 'Content-Type': 'text/html'
See original GitHub issueDescribe the bug Hello, I don’t know if it’s a V8 issue or Axios issue. When I send a get request to get HTML content on a page, a memory leak appear : the html is never stored in garbage collector…
To Reproduce I create a simple server.js with express and axios client to test outside of my project:
const express = require('express');
const axios = require('axios');
const server = express();
const axiosClient = axios.create();
server.get('/axios-test-html', async (req, res) => {
try {
const data = await axiosClient.get('https://github.com/winstonjs/winston-daily-rotate-file/pull/185', {
responseType: 'text',
});
const htmlResponse = data.data;
return res.send({
sourceCode: htmlResponse,
});
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})
server.listen('4242', () => {
console.log('server listen at 4242');
});
process.on('SIGINT', () => {
console.log('server signint');
process.exit(0);
});
I’ve running my server.js with node --inspect
and create heap snapshots at the beginning and after 3/4 calls.
Expected behavior Normally a memory leak does not appear with json content, but with html yes.
Environment:
- Axios Version [e.g. 0.18.0]
- OS: 10.14
- Browser: Chrome
- Browser: Version 71.0.3578.98
- Node.JS : 10.14.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
python - Memory Leak while parsing html page source with ...
So, the basic idea is to make get request to certain list URLs and parse text from those page sources by ...
Read more >4 Types of Memory Leaks in JavaScript and How to Get Rid Of ...
In this article we will explore common types of memory leaks in client-side ... 'http://some.url/image'; button.click(); console.log(text.
Read more >Memory Leaks Demystified - Node.dev
Tracking down memory leaks in Node.js has been a recurring topic, ... writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }) res.write(`Enjoy!
Read more >dwm.exe (Desktop Window Manager) Produces a Memory ...
Describes an issue where drivers newer than 24.20.100.6290 are causing dwm.exe (Desktop Windows Manager) to produce memory leaks.
Read more >Memory Leak in Python requests - GeeksforGeeks
It's a type of resource leak or wastage. When there is a memory leak in the application, the memory of the machine gets...
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mehdibeldji Before PR is merged (if it ever would be 🤣 ) you could pass a custom response transformer that does nothing. This should eliminate the leak.
This seems to be V8 issue caused by
JSON.parse
. I’ve filed a bugreport.The simplest way to reproduce the issue w/o axios