Skip to content

Commit ae5d565

Browse files
Trotttargos
authored andcommitted
test: fix flaky watchFile()
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]>
1 parent b229129 commit ae5d565

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

test/sequential/test-fs-watch-file-enoent-after-deletion.js test/parallel/test-fs-watch-file-enoent-after-deletion.js

-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const common = require('../common');
3232
// stopped it from getting emitted.
3333
// https://github.com/nodejs/node-v0.x-archive/issues/4027
3434

35-
const assert = require('assert');
3635
const path = require('path');
3736
const fs = require('fs');
3837

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

4544
fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) {
46-
assert.strictEqual(prev.nlink, 1);
47-
assert.strictEqual(curr.nlink, 0);
4845
fs.unwatchFile(filename);
4946
}));
5047

0 commit comments

Comments
 (0)