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 7c85557

Browse filesBrowse files
Junliang Yanjasnell
authored andcommitted
test: Fix test-fs-read-stream-fd-leak race cond
Fix intermittent test failure on slower machines. Gives test longer time to complete but checks at regular intervals so that the test only runs longer on slower machines or in the failure case. PR-URL: #3218 Fixes: #3215 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James Snell <jasnell@gmail.com>>
1 parent 1850879 commit 7c85557
Copy full SHA for 7c85557

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎test/parallel/test-fs-read-stream-fd-leak.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read-stream-fd-leak.js
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var _fsopen = fs.open;
1010
var _fsclose = fs.close;
1111

1212
var loopCount = 50;
13+
var totalCheck = 50;
1314
var emptyTxt = path.join(common.fixturesDir, 'empty.txt');
1415

1516
fs.open = function() {
@@ -26,19 +27,27 @@ function testLeak(endFn, callback) {
2627
console.log('testing for leaks from fs.createReadStream().%s()...', endFn);
2728

2829
var i = 0;
30+
var check = 0;
31+
32+
var checkFunction = function() {
33+
if (openCount != 0 && check < totalCheck) {
34+
check++;
35+
setTimeout(checkFunction, 100);
36+
return;
37+
}
38+
assert.equal(0, openCount, 'no leaked file descriptors using ' +
39+
endFn + '() (got ' + openCount + ')');
40+
openCount = 0;
41+
callback && setTimeout(callback, 100);
42+
};
2943

3044
setInterval(function() {
3145
var s = fs.createReadStream(emptyTxt);
3246
s[endFn]();
3347

3448
if (++i === loopCount) {
3549
clearTimeout(this);
36-
setTimeout(function() {
37-
assert.equal(0, openCount, 'no leaked file descriptors using ' +
38-
endFn + '() (got ' + openCount + ')');
39-
openCount = 0;
40-
callback && setTimeout(callback, 100);
41-
}, 100);
50+
setTimeout(checkFunction, 100);
4251
}
4352
}, 2);
4453
}

0 commit comments

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