GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: fix StatWatcher to handle error codes by brendanashworth · Pull Request #2028 · nodejs/node

Conversation

@brendanashworth

@brendanashworth brendanashworth commented Jun 22, 2015

Copy link
Copy Markdown
Contributor

Previously, fs.watchFile() would call the callback even if the file does
not exist. This is erroneous and is fixed by correctly handling the
error code provided.

Ref: nodejs/node-v0.x-archive#25469
Fixes: #1745

CI: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/65/
I just grabbed the commit from joyent/node and doctored it up to fit the new code guidelines for io.js (just the test), squashed and redid the commit log. A note to reviewers: fs.watchFile is not covered at all by the test suite, do not rely on that for checking backwards compatibility.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
thefourtheye
thefourtheye reviewed Jun 22, 2015
View reviewed changes
Comment thread test/parallel/test-fs-watch-file-nonexistent.js Outdated

@thefourtheye thefourtheye Jun 22, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Unused import.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brendanashworth brendanashworth Jun 22, 2015

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, fixed!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Devin Nakamura @brendanashworth
fs: fix StatWatcher to handle error codes
34bd27c
Previously, fs.watchFile() would call the callback even if the file does
not exist. This is erroneous and is fixed by correctly handling the
error code provided.

Ref: nodejs/node-v0.x-archive#25469
Fixes: nodejs#1745
@brendanashworth
brendanashworth force-pushed the fix/fs-watch-nonexistent-file branch from 28b3b30 to 34bd27c Compare June 22, 2015 10:15
bnoordhuis
bnoordhuis reviewed Jun 22, 2015
View reviewed changes
Comment thread test/parallel/test-fs-watch-file-nonexistent.js

@bnoordhuis bnoordhuis Jun 22, 2015

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@thefourtheye pointed out in an earlier revision that this means that the callback won't get called on ENOENT.

I think that already happens if you watch e.g. /etc/shadow because that's going to fail with EPERM or -1, passing the newStatus === -1 check in fs.watchFile().

That does seem unfortunate, though. Invoking the callback at least gives the user a chance to handle the ENOENT case because then you can check that curr.ino > 0.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@thefourtheye thefourtheye Jun 22, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@bnoordhuis Yup, if the callback is not fired then the users will not know if the code is working or not. This could be a debugging nightmare.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brendanashworth brendanashworth Jun 22, 2015

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We can leave this in and mark the current functionality as correct. I marked the issue as confirmed-bug because folks in joyent/node did and ported the PR - but I don't have a strong opinion on whether or not the callback should be called.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@evanlucas evanlucas Jun 30, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If the functionality is different from 0.10, I think we should at least have something in the docs regarding the difference.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mscdex mscdex added the fs Issues and PRs related to file-system APIs and the fs module. label Jun 22, 2015
@rvagg
rvagg force-pushed the master branch from 9d21135 to 628a3ab Compare June 25, 2015 09:18
@brendanashworth brendanashworth mentioned this pull request Jul 1, 2015
fs.watchFile calling listener on non-existing files #1745
Closed
@brendanashworth brendanashworth mentioned this pull request Jul 2, 2015
fs.watchFile fixes #2093
Closed
@brendanashworth

brendanashworth commented Jul 2, 2015

Copy link
Copy Markdown
Contributor Author

I'm going to move ahead with #2093 instead, which keeps current functionality. Thank you everyone.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brendanashworth brendanashworth closed this Jul 2, 2015
@cjihrig cjihrig mentioned this pull request Jul 6, 2015
fs: Fix StatWatcher to handle error codes passed in status nodejs/node-v0.x-archive#25469
Closed
brendanashworth added a commit to brendanashworth/io.js that referenced this pull request Jul 10, 2015
@brendanashworth
doc: document fs.watchFile behaviour on ENOENT
f6467b0
When fs.watchFile encounters an ENOENT error, it invokes the given
callback with some error data. This caused an issue as it was different
behaviour than Node v0.10. Instead of changing this behaviour, document
it and add a test.

Ref: nodejs#1745
Ref: nodejs#2028
brendanashworth added a commit that referenced this pull request Jul 10, 2015
@brendanashworth
doc: document fs.watchFile behaviour on ENOENT
23efb05
When fs.watchFile encounters an ENOENT error, it invokes the given
callback with some error data. This caused an issue as it was different
behaviour than Node v0.10. Instead of changing this behaviour, document
it and add a test.

Ref: #1745
Ref: #2028
Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: #2093
@gr00nd gr00nd mentioned this pull request Feb 6, 2024
[Snyk] Upgrade commander from 2.11.0 to 11.1.0 gr00nd/node#9
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

fs.watchFile calling listener on non-existing files

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@brendanashworth @bnoordhuis @evanlucas @thefourtheye @mscdex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.