Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs: Fix StatWatcher to handle error codes passed in status #25469

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ function StatWatcher() {

this._handle.onchange = function(current, previous, newStatus) {
if (oldStatus === -1 &&
newStatus === -1 &&
newStatus < 0 &&
current.nlink === previous.nlink) return;

oldStatus = newStatus;
Expand Down
15 changes: 15 additions & 0 deletions test/simple/test-fs-watchFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var assert = require('assert');
var fs = require('fs');

function callbackFail(){
assert(false, "Callback should not be called for non-existant files")
}

//regression test for #25345
var filename = 'doesNotExist.txt';
assert(!fs.existsSync(filename), "dummy file exists");
fs.watchFile(filename, callbackFail);

setTimeout(function() {
process.exit()
}, 5000);