Skip to content
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

doc: clarify fs.watch and inodes on linux, os x #6099

Closed
wants to merge 1 commit into from
Closed

doc: clarify fs.watch and inodes on linux, os x #6099

wants to merge 1 commit into from

Conversation

jorangreef
Copy link
Contributor

Checklist
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

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

@r-52 r-52 added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. lts-watch-v4.x labels Apr 7, 2016
<!--type=misc-->

On Linux and OS X systems, `fs.watch` resolves the watched path to an inode. If
the watched path is deleted and then created so that it has a new inode, you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nodejs/documentation is it okay to use "you"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thefourtheye It's consistent with the context, see the previous section on Availability a few lines up:

You can still use...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorangreef Yes, I am not saying its not correct. I just wanted to know what the Docs WG think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We encourage to avoid it. Redacted myself often about this too.
I'd see this as a nit, but worthwhile.
https://github.com/nodejs/docs/blob/master/STYLE-GUIDE.md

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I'd like to see us move away from the informal use of "you" as a best practice. It will take a while to eliminate past usage but I'd prefer not to introduce new instances of it :-)

@stevemao
Copy link
Contributor

stevemao commented Apr 7, 2016

I would link inode to Unix-style file system docs since this is actually not a problem of nodejs itself. The text makes perfect sense to me. Thanks @jorangreef 😄

@jorangreef
Copy link
Contributor Author

Thanks @stevemao, it's linked to "Linux and OS X systems" in the markdown. Do you mean that everything is fine as is? Or would you like any changes?

the watched path is deleted and then created so that it has a new inode, you
will receive an event for the delete but the watch will remain watching the
original inode. You will not receive events for the new inode. This is because
`fs.watch` watches the inode and not the path. This is expected behavior and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.watch()

@Knighton910
Copy link

LGTM when added @Fishrock123 change fs.watch()

@eljefedelrodeodeljefe
Copy link
Contributor

LGTM with nits: you, brackets. Sorry if this was in the discussion, but does the same thing apply for BSDs too? Can be added after landing, since the writing is not exclusive about this.

@jasnell
Copy link
Member

jasnell commented Apr 7, 2016

Generally LGTM but would prefer some of the nits addressed.


<!--type=misc-->

On Linux and OS X systems, `fs.watch` resolves the watched path to an inode. If
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorangreef
I meant maybe we could link inode to http://www.linux.org/threads/intro-to-inodes.4130/ here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link is just an example. If there is better one use that. :)

@jorangreef
Copy link
Contributor Author

Sure, will make the suggested changes.

@jorangreef
Copy link
Contributor Author

@eljefedelrodeodeljefe I did not test on BSD so I am not sure if it applies (it probably does). Linux and OS X were used as examples because these notes are aimed at users coming from Windows who might not expect fs.watch() to work with inodes (see #5039). Users targeting platforms such as BSD, SunOS etc. will probably be aware of inodes. Also, I didn't want to use "Unix-style systems" or "Unix systems" because Windows users might not realize that this includes OS X.

@jorangreef
Copy link
Contributor Author

Done, with suggestions applied.

@eljefedelrodeodeljefe
Copy link
Contributor

@jorangreef fair enough, thx. LGTM then.

@Knighton910
Copy link

+1


On Linux and OS X systems, `fs.watch()` resolves the watched path to an
[inode][]. If the watched path is deleted and then created so that it has a new
inode, an event for the delete will be emitted but the watch will remain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit... Perhaps: When a watched path is deleted and then recreated, it is assigned a new [inode][]. A notification for the deletion event will be emitted but the watch will continue on the *original* inode. Events for the new inode will not be emitted. This is expected behavior.

@jasnell
Copy link
Member

jasnell commented Apr 8, 2016

LGTM with a nit.

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
@jorangreef
Copy link
Contributor Author

Thanks @jasnell, updated the wording.

@jorangreef
Copy link
Contributor Author

This should be ready to merge now?

@eljefedelrodeodeljefe
Copy link
Contributor

Yeah. I think he was just incredible busy since then with a conference and related stuff. Guess there will be around when this lands soon.

Still LGTM and a friendly ping to @jasnell.

@jasnell
Copy link
Member

jasnell commented Apr 18, 2016

Yep, sorry! LGTM! :-)

jasnell pushed a commit that referenced this pull request Apr 18, 2016
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>
@jasnell
Copy link
Member

jasnell commented Apr 18, 2016

Landed in 88c35e7

@jasnell jasnell closed this Apr 18, 2016
MylesBorins pushed a commit that referenced this pull request Apr 19, 2016
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>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
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>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
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>
@MylesBorins MylesBorins mentioned this pull request Apr 20, 2016
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
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>
This was referenced Apr 21, 2016
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
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>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
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: nodejs#5039
PR-URL: nodejs#6099
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell pushed a commit that referenced this pull request Apr 26, 2016
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>
MylesBorins pushed a commit that referenced this pull request May 3, 2016
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>
MylesBorins pushed a commit that referenced this pull request May 6, 2016
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>
MylesBorins pushed a commit that referenced this pull request May 18, 2016
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>
@MylesBorins MylesBorins mentioned this pull request May 18, 2016
@fatonsopa
Copy link

Hi guys,

this is still happening:

npm -v 3.10.10
node -v v6.11.5
MacOS Sierra 10.12.6

The file.watch is triggering the change only once per file. In windows is working perfectly.

Researched a lot but couldn't find a working solution. Any idea?

Thanks,
Faton

@thefourtheye
Copy link
Contributor

@fatonsopa That is the expected behavior. This PR just documented it properly.

@fatonsopa
Copy link

@thefourtheye Thanks. I didn't get the PR!
Is there any way I can make it work in all OS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mac: fs.watch() not detecting changes to file from git operation
10 participants