Skip to content

Commit

Permalink
test,fs: delay unlink in test-regress-GH-4027.js
Browse files Browse the repository at this point in the history
The sequential/test-regress-GH-4027 test is flaky with an increased
system load, failing when the watched file is unlinked before the
first state of the watched file is retrieved.

After increasing the delay before unlinking and calling setTimeout
after watchFile, the flakiness stopped reproducing.

PR-URL: #14010
Fixes: #13800
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
jaimecbernardo authored and MylesBorins committed Aug 15, 2017
1 parent c5a427f commit 03a5c5a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/sequential/test-regress-GH-4027.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ common.refreshTmpDir();

const filename = path.join(common.tmpDir, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes');
setTimeout(fs.unlinkSync, 100, filename);

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

setTimeout(fs.unlinkSync, common.platformTimeout(300), filename);

0 comments on commit 03a5c5a

Please sign in to comment.