Repository navigation
fs: is fs.unwatchFile() available on Windows? #18305
Copy link
Copy link
Closed
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Description
Activity
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Jan 23, 2018 This works as intended:
'use strict'; const fs = require('fs'); const watcher = fs.watch(__filename, (eventType) => { console.log(eventType); watcher.close(); console.log('watcher.close() called'); });
change watcher.close() called [exit]
The listener argument passed to
fs.unwatchFileshould be a callback function that was previously registered withfs.watchFileand is not expected to be called as part of the invocation offs.unwatchFile.To clarify, in your example the
fs.unwatchFilecall does not remove the listener registered with thefs.watchFilecall so never exits because there is still an active registered callback.@richardlau Thank you! This do work as intended:
'use strict'; const fs = require('fs'); const listener = (current, previous) => { console.log(current.size, previous.size); fs.unwatchFile(__filename, listener); console.log('unwatchFile() called'); } fs.watchFile(__filename, { interval: 1000 }, listener);
I was misguided by the listener signature in last descriptions:
Is this signature intended? Added here: #13424
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Jan 23, 2018 - added a commit that references this issue
on Feb 27, 2018 - added a commit that references this issue
on May 8, 2018 - added a commit that references this issue
on Jul 27, 2026
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Launch it, then change and save several times.
Expected output:
Real output
I cannot find any caveats in
fsdoc about this. Is there any?