Skip to content

Commit 88c35e7

Browse files
jorangreefjasnell
authored andcommitted
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 <jasnell@gmail.com>
1 parent b95160d commit 88c35e7

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
@@ -1155,6 +1155,16 @@ reliably or at all.
11551155
You can still use `fs.watchFile`, which uses stat polling, but it is slower and
11561156
less reliable.
11571157

1158+
#### Inodes
1159+
1160+
<!--type=misc-->
1161+
1162+
On Linux and OS X systems, `fs.watch()` resolves the path to an [inode][] and
1163+
watches the inode. If the watched path is deleted and recreated, it is assigned
1164+
a new inode. The watch will emit an event for the delete but will continue
1165+
watching the *original* inode. Events for the new inode will not be emitted.
1166+
This is expected behavior.
1167+
11581168
#### Filename Argument
11591169

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

0 commit comments

Comments
 (0)