[bug]: file watching can cause memory leak
gikf opened this issue · comments
Trouble seem to be caused as a joined effort from file watcher - chokidar
and symlinks appearing in node_modules/
folder. When package is leading back to node_modules/
(and further to package), this makes chokidar
going deeper and deeper, until garbage collector is no longer able to collect quickly enough and memory is depleted.
Currently chokidar
is not making any actions on changes in certain folders (including node_modules/
), but that doesn't stop it from trying to find the end of the symlinks path.
I've tried to make ignored
option work, which appears deal with the issue, after small change to the hotReload.ignore
config option patterns. Ie. said /node_modules/
has to be changed to **/node_modules/**
.
Another way I tested is using ignored
option with function, this wouldn't require changing patterns to ignore:
ignored: (p) => !pathsToIgnore.includes(p),
Finally, another chokidar
option - followSymlinks
sounds like it also should give ability to fix the problem. I haven't tested it though.
Originally posted by @ShaunSHamilton in #274 (comment)
I did not even think to look at the node_modules, because I assumed the ignore was working properly.
ignored: (p) => !pathsToIgnore.includes(p),
Previously, I tried this:
freeCodeCampOS/.freeCodeCamp/tooling/hot-reload.js
Lines 26 to 27 in dae2499
With no success. It sounds like the callback should return false
for paths that should be ignored
then?
Sorry, I confused it excluding everything with excluding only wanted ones.
This is the working version:
ignored: (path) => pathsToIgnore.some(p => path.includes(p)),