Skip to content

Commit

Permalink
test: fix flaky watchFile()
Browse files Browse the repository at this point in the history
The regression that test-fs-watch-file-enoent-after-deletion was written
to test for involves whether or not the callback runs or not. Checking
what the file watcher reports unfortunately is subject to race
conditions on Windows (and possibly elsewhere) because the file watcher
returns control to the event loop before it may be receiving data from
the OS. So remove those assertions. The test still checks what it is
supposed to check, but is no longer subject to race conditions.

Fixes: #21692

PR-URL: #21694
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Trott authored and targos committed Jul 14, 2018
1 parent b229129 commit ae5d565
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const common = require('../common');
// stopped it from getting emitted.
// https://github.com/nodejs/node-v0.x-archive/issues/4027

const assert = require('assert');
const path = require('path');
const fs = require('fs');

Expand All @@ -43,8 +42,6 @@ const filename = path.join(tmpdir.path, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes');

fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) {
assert.strictEqual(prev.nlink, 1);
assert.strictEqual(curr.nlink, 0);
fs.unwatchFile(filename);
}));

Expand Down

0 comments on commit ae5d565

Please sign in to comment.