Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0476c5

Browse filesBrowse files
TrottMyles Borins
authored andcommitted
test: fix flaky test-fs-watch-recursive on OS X
The test was sometimes timing out due to a race condition. In OS X, events for `fs.watch()` might only start showing up after a delay. This is a limitation of the operating system. To work around that, there was a timer in the test that delayed the writing of the file by 100ms. However, sometimes that was not enough, and so the event never fired, and the test timed out. Change the timer to an interval so that it fires repeatedly until it is picked up. This change only affects OS X. Fixes: #8511 PR-URL: #9303 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent bcd156f commit b0476c5
Copy full SHA for b0476c5

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-fs-watch-recursive.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ watcher.on('change', function(event, filename) {
3232
if (filename !== relativePathOne)
3333
return;
3434

35+
if (common.isOSX) {
36+
clearInterval(interval);
37+
}
3538
watcher.close();
3639
watcherClosed = true;
3740
});
3841

39-
if (process.platform === 'darwin') {
40-
setTimeout(function() {
42+
if (common.isOSX) {
43+
var interval = setInterval(function() {
4144
fs.writeFileSync(filepathOne, 'world');
42-
}, 100);
45+
}, 10);
4346
} else {
4447
fs.writeFileSync(filepathOne, 'world');
4548
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.