Skip to content

Commit 6263c00

Browse files
committed
test: provide duration/interval to timers
There are places in the code base where setTimeout() or setInterval() are called with just a callback and no duration/interval. The timers module will use a value of `1` in that situation. An unspecified duration or interval can be confusing. Did the original author forget to provide a value? Did they intend to use setImmediate() or process.nextTick() instead of setTimeout()? And so on. This change provides a duration or interval of `1` to all calls in the codebase where it is missing. `parallel/test-timers.js` still tests the situation where `setTimeout()` and `setInterval()` are called with `undefined` and other non-numeric values for the duration/interval. PR-URL: #9472 Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 38b18e3 commit 6263c00

6 files changed

+9
-9
lines changed

test/message/timeout_throw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ require('../common');
44
setTimeout(function() {
55
// eslint-disable-next-line no-undef
66
undefined_reference_error_maker;
7-
});
7+
}, 1);

test/parallel/test-handle-wrap-close-abort.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ setTimeout(function() {
1313
setTimeout(function() {
1414
throw new Error('setTimeout');
1515
}, 1);
16-
});
16+
}, 1);

test/parallel/test-stream-end-paused.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ stream.pause();
2121
setTimeout(common.mustCall(function() {
2222
stream.on('end', common.mustCall(function() {}));
2323
stream.resume();
24-
}));
24+
}), 1);
2525

2626
process.on('exit', function() {
2727
assert(calledRead);

test/parallel/test-stream-readable-event.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Readable = require('stream').Readable;
2020
// we're testing what we think we are
2121
assert(!r._readableState.reading);
2222
r.on('readable', common.mustCall(function() {}));
23-
});
23+
}, 1);
2424
}
2525

2626
{
@@ -40,7 +40,7 @@ const Readable = require('stream').Readable;
4040
// assert we're testing what we think we are
4141
assert(r._readableState.reading);
4242
r.on('readable', common.mustCall(function() {}));
43-
});
43+
}, 1);
4444
}
4545

4646
{
@@ -60,5 +60,5 @@ const Readable = require('stream').Readable;
6060
// assert we're testing what we think we are
6161
assert(!r._readableState.reading);
6262
r.on('readable', common.mustCall(function() {}));
63-
});
63+
}, 1);
6464
}

test/parallel/test-stream2-large-read-stall.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function push() {
4646

4747
console.error(' push #%d', pushes);
4848
if (r.push(Buffer.allocUnsafe(PUSHSIZE)))
49-
setTimeout(push);
49+
setTimeout(push, 1);
5050
}
5151

5252
process.on('exit', function() {

test/parallel/test-stream2-readable-non-empty-end.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test._read = function(size) {
1616
var chunk = chunks[n++];
1717
setTimeout(function() {
1818
test.push(chunk === undefined ? null : chunk);
19-
});
19+
}, 1);
2020
};
2121

2222
test.on('end', thrower);
@@ -31,7 +31,7 @@ test.on('readable', function() {
3131
if (res) {
3232
bytesread += res.length;
3333
console.error('br=%d len=%d', bytesread, len);
34-
setTimeout(next);
34+
setTimeout(next, 1);
3535
}
3636
test.read(0);
3737
});

0 commit comments

Comments
 (0)