-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
Is your feature request related to a problem? Please describe.
Currently, when you do fs.watchFile(...)
the process will run forever.
Describe the solution you'd like
A possibility to watcher.unref()
would be great.
Describe alternatives you've considered
const watchFile = (path, callback, onError) => {
let previousTime = null;
const interval = setInterval(async () => {
try {
const {mtimeMs} = await stat(path);
if (previousTime !== null && mtimeMs !== previousTime) {
callback(mtimeMs, previousTime);
}
previousTime = mtimeMs;
} catch (error) {
clearInterval(interval);
// The error part is off the Node.js API
onError(error);
}
}, 1000 * 60).unref();
};
Edit: seems like the code above is completely unnecessary 🤦♂️
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.