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
Enable hooks in fs.statWatchers #33569
Comments
I think this feature would be necessary In Linux or other platforms, the file watcher is very expensive resources for user. For example, there are some limit about file watcher count for the unique user id in Linux So I think it would be necessary to allow people get a way to trace/output log/do other things meaningful for their 'file watch' action |
Two questions:
|
Yes, it do is the global limit, but sometimes we need to monitor which module reach the limit.
I noticed that we already have |
I don’t really understand how this relates to the difference between
I guess to be more explicit, what is the advantage of using an |
Just getting back around on this issue. I don't know if it's still something that is needed, but it should be possible to do what you want here (or get close) using an async_hook: const { createHook } = require('async_hooks');
const set = new Set();
const hook = createHook({
init(id, type) {
if (type === 'FSEVENTWRAP') set.add(id);
},
destroy(id) {
set.delete(id);
}
});
hook.enable();
const { watch } = require('fs');
// The size is the number of active watchers...
setInterval(() => console.log(set.size), 1000);
let w;
setTimeout(() => w = watch(__filename), 500);
setTimeout(() => w.close(), 1500); It can be expensive so you wouldn't want to have this enabled all the time, but to determine which code path created the watch, you should be able to do something like: const map = new Map();
const hook = createHook({
init(id, type) {
if (type === 'FSEVENTWRAP') {
const err = new Error();
map.put(id, err.stack);
}
},
destroy(id) {
set.delete(id);
}
}); |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
Is your feature request related to a problem? Please describe.
People sometimes will encounter the error that
System limit for number of file watchers reached.
. If we enable users to add hooks in fs.statWatchers, they could track the codes that which module callfs.watchFile
many timesDescribe the solution you'd like
Related code
node/lib/fs.js
Line 1458 in 9949a2e
The text was updated successfully, but these errors were encountered: