From e0dfdd23c714390fb35577feeb4d903df01b479f Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Fri, 30 Jun 2017 19:35:52 +0100 Subject: [PATCH 1/2] test,fs: delay unlink in test-regress-GH-4027.js 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. Fixes: https://github.com/nodejs/node/issues/13800 --- test/sequential/test-regress-GH-4027.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-regress-GH-4027.js index e3e9e5a4de4ef6..a13e31931ace91 100644 --- a/test/sequential/test-regress-GH-4027.js +++ b/test/sequential/test-regress-GH-4027.js @@ -29,10 +29,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, 300, filename); From 0de303485865369eb174b40a838d3be6dd43dbb2 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Sat, 1 Jul 2017 16:13:49 +0100 Subject: [PATCH 2/2] fixup: use common.platformTimeout Refs: https://github.com/nodejs/node/pull/14010#pullrequestreview-47500808 --- test/sequential/test-regress-GH-4027.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-regress-GH-4027.js index a13e31931ace91..6ab6afcfd6bc2e 100644 --- a/test/sequential/test-regress-GH-4027.js +++ b/test/sequential/test-regress-GH-4027.js @@ -36,4 +36,4 @@ fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) { fs.unwatchFile(filename); })); -setTimeout(fs.unlinkSync, 300, filename); +setTimeout(fs.unlinkSync, common.platformTimeout(300), filename);