-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
I wanted to test a URL for validity; verifying that it returns a 200 response.
Using this code:
const fetch = require('node-fetch');
module.exports = (url) => fetch(url)
.then(res => res.status === 200 && url);
...I found it caused a memory leak. Node that I"m not calling .body() or .json(). Profiling the memory usage over time, I was suspicious that lots of stream objects were being keep in memory. I speculatively added {method: 'HEAD'} to the options (which is of course the right thing to do in this case anyway), which fixed the memory leak.
Is this a bug in node-fetch? Should memory be freed whether or not the body of the response is ever used? If it's not a bug, I wonder if the documentation should make it clear that responses with a body must be cleared in some way to free memory?
Thanks for a great library!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels