got-fetch icon indicating copy to clipboard operation
got-fetch copied to clipboard

Memory Leak from cache option in got

Open spence-s opened this issue 2 years ago • 1 comments

By default got-fetch adds a simple Map cache to the got options which is currently buggy in got.

Perhaps we could provide a way to turn the cache option off until it is fixed.

Related to https://github.com/sindresorhus/got/issues/1128 https://github.com/sindresorhus/got/issues/1523

import {fetch} from 'got-fetch';

let response = await fetch('https://www.youtube.com');

for (let i = 0; i < 1000; i++) {
  response = await fetch('https://www.youtube.com');
}

// (node:40746) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Keyv]. 
// Use emitter.setMaxListeners() to increase limit
// (Use `node --trace-warnings ...` to show where the warning was created)

spence-s avatar Sep 29 '22 19:09 spence-s

https://github.com/sindresorhus/got/issues/1523#issuecomment-726065795

okko avatar Nov 22 '22 13:11 okko