Skip to content

Commit 5f9c829

Browse files
jorangreefMyles Borins
authored and
Myles Borins
committed
doc: clarify fs.watch() and inodes on linux, os x
On Linux and OS X systems, `fs.watch()` resolves the watched path to an inode. This clarifies that `fs.watch()` watches the inode and not the path. If the inode of the path subsequently changes, `fs.watch()` will continue watching the original inode and events for the path will no longer be emitted. This is expected behavior. Fixes: #5039 PR-URL: #6099 Reviewed-By: James M Snell <[email protected]>
1 parent d809c84 commit 5f9c829

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/api/fs.markdown

+11
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,16 @@ reliably or at all.
869869
You can still use `fs.watchFile`, which uses stat polling, but it is slower and
870870
less reliable.
871871

872+
#### Inodes
873+
874+
<!--type=misc-->
875+
876+
On Linux and OS X systems, `fs.watch()` resolves the path to an [inode][] and
877+
watches the inode. If the watched path is deleted and recreated, it is assigned
878+
a new inode. The watch will emit an event for the delete but will continue
879+
watching the *original* inode. Events for the new inode will not be emitted.
880+
This is expected behavior.
881+
872882
#### Filename Argument
873883

874884
<!--type=misc-->
@@ -1053,3 +1063,4 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
10531063
[MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
10541064
[Readable Stream]: stream.html#stream_class_stream_readable
10551065
[Writable Stream]: stream.html#stream_class_stream_writable
1066+
[inode]: http://www.linux.org/threads/intro-to-inodes.4130

0 commit comments

Comments
 (0)